Not in List - Refresh

G

Guest

I have a form (LOCATIONS) with a combo box. The NotInList property is set to
yes. I created a new form (Add New) with data entry set to yes. If an
account number is typed into the combo box and not found, I want to open the
Add New form and enter the data. When I close that form, and go back to the
Locations form I want to type in the number I just added and bring up the
record. So I assume this form has to close and reopen somewhere along the
line.

Here is the code I have for the NotInList event.

Private Sub Combo48_NotInList(NewData As String, Response as Integer)
Dim strMsg As String, strTitle As String
strMsg = "Account Not Found. Add New Account?"
strTitle = "Add New Account?"

If MsgBox(strMsg, vbQuestion + vbYesNo, strTitle) = vbYes Then
DoCmd.OpenForm "AddNew",,,,acFormAdd, acDialog
response = acDataErrAdded
Else
response = acDataErrContinue
End If
Exit_Combo48_NotInLList:
End Sub

At what point would I close and reopen Locations?
Also, I need some error handling, which I haven't had any luck adding.

Thanks,
 
D

Dirk Goldgar

Howard said:
I have a form (LOCATIONS) with a combo box. The NotInList property is
set to yes. I created a new form (Add New) with data entry set to
yes. If an account number is typed into the combo box and not found,
I want to open the Add New form and enter the data. When I close that
form, and go back to the Locations form I want to type in the number
I just added and bring up the record. So I assume this form has to
close and reopen somewhere along the line.

Here is the code I have for the NotInList event.

Private Sub Combo48_NotInList(NewData As String, Response as Integer)
Dim strMsg As String, strTitle As String
strMsg = "Account Not Found. Add New Account?"
strTitle = "Add New Account?"

If MsgBox(strMsg, vbQuestion + vbYesNo, strTitle) = vbYes Then
DoCmd.OpenForm "AddNew",,,,acFormAdd, acDialog
response = acDataErrAdded
Else
response = acDataErrContinue
End If
Exit_Combo48_NotInLList:
End Sub

At what point would I close and reopen Locations?
Also, I need some error handling, which I haven't had any luck adding.

Thanks,

Is your combo intended to find a record on the Locations form? Is the
AddNew form adding a record to the same underlying recordsource, so that
you need to requery Locations after adding it? If so, you don't need to
close and reopen the form, but you do need to requery it:

Me.Requery
 
G

Guest

Try this (I'm not sure if this is really what you are asking for)
'Make the new value show in the combo box after it is added to the list.'
In the OnGotFocus event property of the combo box type: Me.Refresh
Example:
Private Sub EmployeeID_GotFocus()
Me.Refresh
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top