Dropdown Won't Requery Using ADO

Lynn_AccessUser

Registered User.
Local time
Yesterday, 23:44
Joined
Feb 4, 2003
Messages
125
The following code allows a user to type in a record in
the dropdown box and if the record does not exists it
prompts the user to add the record via another form. The
problem is the drop down will not requery. It works in
DAO but not ADO.

The record does get added to the table but the user has to
close the form and then reopen it to see the new record in
the drop down box.

Any suggestions?

Private Sub cboVendor_NotInList(NewData As String,
Response As Integer)

Dim strMsg As String


strMsg = "Vendor not on list. Would you like to add
it?"

If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "New
Vendor") Then
pintResponse = acDataErrContinue
MsgBox "You must select from the dropdown list or
add the Vendor.", vbOKCancel
Else
DoCmd.OpenForm "frmAddEditVendor", , , , , acDialog
pintResponse = acDataErrAdded

End If

End Sub
 
Try putting a requery here:
Else
DoCmd.OpenForm "frmAddEditVendor", , , , , acDialog
cboVendor.requery
pintResponse = acDataErrAdded
 
The problem stems from these lines:
pintResponse = acDataErrContinue
pintResponse = acDataErrAdded

Notice in the Sub declaration that the variable is called "Response". Change the lines to:
Response = acDataErrContinue
and
Response = acDataErrAdded

The acDataErrAdd will take care of requerying the combo box for you.

This is more of a VBA problem, so I don't understand why this code would even work in DAO.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom