View Single Post
  #2  
Old December 22nd, 2004, 06:20 PM
Andi Mayer
external usenet poster
 
Posts: n/a
Default

On Wed, 22 Dec 2004 11:50:23 -0500, "Jan Il"
wrote:

Hi all - Access 2000 XP, W2K

I have a data entry form with a control to enter transactions to the table,
set to LimitToList. I want to be able to add a new transaction at the time
the entry is being made, so that the user does not have to go to the table
to enter the new Transaction. I have the code in the NotInList event and
the add dialog box comes up fine, but, when I enter the new Transaction and
try to go to the next entry control, I get an error message that say:

"Error: The field 'MyCheckRegister.TransactionDate' cannot have a Null value
because the Required property for this field is set to True. Enter a value
in this field."

There is a date entered in that control on the form. Here is the code that I
now have for the Transaction control to add the new Transaction:

/Start Code/
*****************************
Private Sub cmbTransaction_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_Handler
Dim rst As DAO.Recordset
Dim lngTransaction As Long

If MsgBox(NewData & " ... not in list, add it?", _
vbOKCancel, "New Transaction") = vbOK Then
Set rst = CurrentDb.OpenRecordset("MyCheckRegister")
With rst
.AddNew
.Fields("Transaction") = NewData


the error is he
your table needs the TransactionDate set to a Value,
because addnew adds this field with a Null Value

.Fields("TransactionDate") = me.TransactionDate


.Update
.Bookmark = .LastModified
lngTransaction = .Fields("Transaction")
.Close
End With
Response = acDataErrAdded
DoCmd.OpenForm FormName:="frmCkEntry", _
wherecondition:="Transaction =" & lngTransaction, _
WindowMode:=acDialog
Else
Response = acDataErrContinue
End If

Exit_He
Set rst = Nothing
Exit Sub
Err_Handler:
Response = acDataErrContinue
MsgBox "Error: " & Err.Description
Resume Exit_Here
End Sub
***************************
/End Code/

The date control works fine with no error message when I enter the date and
tab to the Transaction control. It is only after the new Transaction has
been added and tabbing to the next entry that the error message gets fired.

I have been over and over the code and form controls and such, but, I can't
find where the problem is. I would truly appreciate it if someone could
point me in the right direction here to correct this problem.

Jan
Smiles are meant to be shared,
that's why they're so contagious.





If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW