L
Little Penny
I have a UserID field that is in a form Called Computer and Users. The UseID field is the primary key to the UserInfo Table The Users table and
Computers table are joined (one to Many} by the UserID are in a query which is the record set for the form. My UserID field in the form is set to
limit to list. The drop down show 3 columns (UserID First and Last name) only the UserID is bound to field. I want to
1. If user enter UserID the not in list a MsgBox letting the user know and giving option to add to list. If they say no it undoes the changes and
goes back the the UserID field . If yes open another form to add user as well as undo any changes. I tried to tweak this code I have below but I'm
stuck. Everything work except yes option. It opens the form but I get a msg saying The text you entered is not in list please select from list. Also
it does not undo chages to UserID field.
I know I will also need a code to re populate the query on the form. But I guess I have to get this going first.
Private Sub UserID_NotInList(NewData As String, Response As Integer)
On Error GoTo UserID_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The User ID " & Chr(34) & NewData & _
Chr(34) & " is not currently in the in User ID list." & vbCrLf & _
"Would you like to add a new User to the list now?" _
, vbQuestion + vbYesNo, "User ID ")
If intAnswer = vbYes Then
DoCmd.OpenForm "frm_UserInfo"
Else
MsgBox "Please choose a User ID from the list." _
, vbInformation, "User ID"
Response = acDataErrContinue
Me.UserID.Undo
End If
UserID_NotInList_Exit:
Exit Sub
UserID_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume UserID_NotInList_Exit
End Sub
Thanks
Computers table are joined (one to Many} by the UserID are in a query which is the record set for the form. My UserID field in the form is set to
limit to list. The drop down show 3 columns (UserID First and Last name) only the UserID is bound to field. I want to
1. If user enter UserID the not in list a MsgBox letting the user know and giving option to add to list. If they say no it undoes the changes and
goes back the the UserID field . If yes open another form to add user as well as undo any changes. I tried to tweak this code I have below but I'm
stuck. Everything work except yes option. It opens the form but I get a msg saying The text you entered is not in list please select from list. Also
it does not undo chages to UserID field.
I know I will also need a code to re populate the query on the form. But I guess I have to get this going first.
Private Sub UserID_NotInList(NewData As String, Response As Integer)
On Error GoTo UserID_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The User ID " & Chr(34) & NewData & _
Chr(34) & " is not currently in the in User ID list." & vbCrLf & _
"Would you like to add a new User to the list now?" _
, vbQuestion + vbYesNo, "User ID ")
If intAnswer = vbYes Then
DoCmd.OpenForm "frm_UserInfo"
Else
MsgBox "Please choose a User ID from the list." _
, vbInformation, "User ID"
Response = acDataErrContinue
Me.UserID.Undo
End If
UserID_NotInList_Exit:
Exit Sub
UserID_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume UserID_NotInList_Exit
End Sub
Thanks