Not in list problem

A

allie357

Okay, I have a Not In List event that allows me to add a new person to
a list by asking if we want to add them and it opens a second form that
allows the user to input a person's first and last name into the
corresponding table and adds them to the list. However, when I push the
cancel button (if the user changes their mind) I cannot get the combo
box to clear. I tried adding code that would set the combo to null but
it keeps saying object required. I want to make sure I have all the
proper error handling, but I lost on how to accomplish this...

Here is the code: (Not In List)

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

If Len(NewData & "") > 0 Then

If MsgBox("[" & NewData & "] is not in the list." & vbCr & vbCr &
"Do you want to add it?", vbQuestion + vbYesNo) = vbYes Then



DoCmd.OpenForm "frmNewViolator", acNormal, , , acFormAdd,
acDialog, NewData
Response = acDataErrContinue

Response = acDataErrAdded '-- Causes the ComboBox to requery

Else
Me.cbo_Violator_ID = Null
Response = acDataErrContinue

End If

Else
Me.cbo_Violator_ID = Null
Response = acDataErrContinue

End If

End Sub


Code (new person form):

Option Compare Database
Private Sub subClearFields()
ViolatorFirstName = Null
ViolatorLastName = Null

End Sub

Private Sub AddViolator_Click()
On Error GoTo Err_AddViolator_Click
If Me.Dirty Then
RunCommand acCmdSaveRecord
End If

DoCmd.Close

Exit_AddViolator_Click:
Exit Sub

Err_AddViolator_Click:
MsgBox Err.Description
Resume Exit_AddViolator_Click

End Sub

Private Sub ClearViolator_Click()
Call subClearFields
End Sub



Private Sub Cancel_Click()
On Error GoTo Err_Cancel_Click


DoCmd.Close


Exit_Cancel_Click:
Exit Sub

Err_Cancel_Click:
MsgBox Err.Description
Resume Exit_Cancel_Click

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

Top