Not in list trouble

A

allie357

I have a form that allows me to add a new person to a list via the not
in list event. It opens a seperate form that allows the user to add a
person's first and last name to the combo box and requeries. My problem
occurs when I push the cancel button on the seperate form (if I decide
not to add the person). The form closes but I cannot get the combo box
on the first form to clear. I tried setting the field to null in the
code for the cancel button but that did not work. I keep getting the
error Object required. I am also concerned about the lack of error
handling in both places but I am kind of lost in that area.

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
(Seperate New Violator 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

Similar Threads

Not in list problem 1
Not in List Event 4
Not on list event 1
combo box not in list trouble 7
Not in list Problem 6
using multiple fields from a table 3
Add a Duplicate Record 5
error 3011 in case 4 only 1

Top