J
Jan Il
Hi all! Windows XP Pro - Access 2002 XP
The code below is in the NotInList event of a combo box on a data entry
form.
*****Begin Code*********
Private Sub cmbTransaction_NotInList(NewData As String, Response As Integer)
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 Record") = vbOK Then
Set rst = CurrentDb.OpenRecordset("MyCheckRegister")
With rst
.AddNew
.Fields("cmbTransaction") = NewData
.Update
.Bookmark = .LastModified
lngTransaction = .Fields("cmbTransaction")
.Close
End With
Response = acDataErrAdded
DoCmd.OpenForm FormName:="frmAddTransaction", _
wherecondition:="cmbTransction=" & lngTransaction, _
WindowMode:=acDialog
Else
Response = acDataErrContinue
End If
***********************End Code******************
The purpose of the two is so that when a transaction is found not to be in
the list during normal data entry processing, a message will appear and say
it is not in the list, would you like to add a new record. When the user
clicks yes, then a separate from is opened to allow the new data to be added
to the table. When the new data is saved, the second form will close and
return to the data entry form so that the user can continue with other data
entry. This will allow the user to enter new data much faster and easier
when it comes up during the normal entry process. I have a similar set up
in another form for adding new vendors and it works perfectly. However, I
am getting an error message when I click the command button to open the
second entry form to add the new data to the table, and the debugger also
points to the second line of code from the top above.
The error message says:
The expression On Click you entered as the event property setting produced
the following error: Ambiguous name detected: cmbTransaction_NotInList.
*The expression may result in the name of a macro, the name of a user...etc.
I have gone over the code until I'm blind and just can't find where the
error might be. There is no other name like that in the database, so I don't
know why it is barking at that part of the code.
I would truly appreciate if someone could point me in the right direction of
where to look to troubleshoot further, or perhaps where the code is not
correct. I may just be overlooking something there.
Jan
Smiles are meant to be shared,
that's why they're so contagious.
The code below is in the NotInList event of a combo box on a data entry
form.
*****Begin Code*********
Private Sub cmbTransaction_NotInList(NewData As String, Response As Integer)
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 Record") = vbOK Then
Set rst = CurrentDb.OpenRecordset("MyCheckRegister")
With rst
.AddNew
.Fields("cmbTransaction") = NewData
.Update
.Bookmark = .LastModified
lngTransaction = .Fields("cmbTransaction")
.Close
End With
Response = acDataErrAdded
DoCmd.OpenForm FormName:="frmAddTransaction", _
wherecondition:="cmbTransction=" & lngTransaction, _
WindowMode:=acDialog
Else
Response = acDataErrContinue
End If
***********************End Code******************
The purpose of the two is so that when a transaction is found not to be in
the list during normal data entry processing, a message will appear and say
it is not in the list, would you like to add a new record. When the user
clicks yes, then a separate from is opened to allow the new data to be added
to the table. When the new data is saved, the second form will close and
return to the data entry form so that the user can continue with other data
entry. This will allow the user to enter new data much faster and easier
when it comes up during the normal entry process. I have a similar set up
in another form for adding new vendors and it works perfectly. However, I
am getting an error message when I click the command button to open the
second entry form to add the new data to the table, and the debugger also
points to the second line of code from the top above.
The error message says:
The expression On Click you entered as the event property setting produced
the following error: Ambiguous name detected: cmbTransaction_NotInList.
*The expression may result in the name of a macro, the name of a user...etc.
I have gone over the code until I'm blind and just can't find where the
error might be. There is no other name like that in the database, so I don't
know why it is barking at that part of the code.
I would truly appreciate if someone could point me in the right direction of
where to look to troubleshoot further, or perhaps where the code is not
correct. I may just be overlooking something there.
Jan
Smiles are meant to be shared,
that's why they're so contagious.