Hi all,
I have a combo (CboAddressType) with a not in list. There is an sql statement in it to put it in a table, then open up the form i want to link criteria too to fill in an address. Below is code but when i run this it opens form (AddressFrm) but i get a not on list msg, have to select from the list which its there? Why is this not recognizing that this was just put in the table. Form is run off a query but before form opens up, it should not qry correct?
I am looking to have this put my TXT in table, then open form to that record i just added so i dont get this not in list dialog when the form opens up? I cant figure it out. Some where it needs to requery the qry before it opens up the form? I dont know. Any assistance would be just fantastic!
Thanks
Dave
Code:
Private Sub CboAddressType_NotInList(NewData As String, Response As Integer)
Dim strsql As String, x As Integer
Dim LinkCriteria As String
x = MsgBox("Address Type is not in Current List, Would you Like to Add?", vbYesNo)
If x = vbYes Then
strsql = "Insert Into AddressTypeTbl ([AddressType]) values ('" & NewData & "')"
'MsgBox strsql
CurrentDb.Execute strsql, dbFailOnError
LinkCriteria = "[AddressType] = '" & Me!CboAddressType.Text & "'"
DoCmd.OpenForm "AddressFrm", , , , , , Me.CboAddressType
Forms!AddressFrm!CboPerson = PersonID
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub