mtagliaferri
Registered User.
- Local time
- Today, 20:53
- Joined
- Jul 16, 2006
- Messages
- 550
Hi all, I have copied a code to show a not in list on a combo box, what should do is if the value in the combo box is not in list a message appears askink if you would like to add the data and if yes it open a form to add the new data, when closing the form once added the record it gives a error as:
ERROR ON RUN TIME "3464", the code I have is
Highlighting the Dlookup...
I immagine I havent copied completely the informatio, can I get any help?
Thanks
Marco
ERROR ON RUN TIME "3464", the code I have is
Code:
Private Sub StaffNumber_NotInList(NewData As String, Response As Integer)
Dim strName As String, strWhere As String
' User typed in a product type that's not in the list
strName = NewData
' Build the verification search string
strWhere = "[StaffNumber] = '" & strName & "'"
' Verify that they want to add the new Contact Type
If vbYes = MsgBox("Crew Member " & NewData & " is not defined. " & _
"Do you want to add this Crew Member?", vbYesNo + vbQuestion + vbDefaultButton2, gstrAppTitle) Then
' Open the add a Product Type form and pass it the new value
' NOTE: For this simple lookup value we could do an SQL Insert,
' but this method gives the user one extra chance to verify the value.
DoCmd.OpenForm "Crew Members", DataMode:=acFormAdd, WindowMode:=acDialog, _
OpenArgs:=strName
' Code will wait until "add" form closes - now verify that it got added!
[B]If IsNull(DLookup("StaffNumber", "Crew Member", strWhere)) Then[/B]
' Ooops
MsgBox "You failed to add a Crew Member that matched what you entered. Please try again.", vbInformation, gstrAppTitle
' Tell Access we handled the error, but cancel the update
Response = acDataErrContinue
Else
' Tell Access new data was added
Response = acDataErrAdded
End If
Else
' Don't want to add what they typed - show standard error message
Response = acDataErrDisplay
End If
End Sub
I immagine I havent copied completely the informatio, can I get any help?
Thanks
Marco