B
Barry A&P
i have an unbound combobox that will set criteria for a query
i want to however give the option of if the value is not in the list open up
a form and add it or cancel out and clear the combo box.
heres the my code so far..
Private Sub PartNumberCombo_BeforeUpdate(Cancel As Integer)
Dim lnganswer As String
If Me.PartNumberCombo.ListIndex = -1 Then
lnganswer = MsgBox(Me!PartNumberCombo.Text & " is not in the list would you
like to add it?", vbOKCancel)
Select Case lnganswer
Case vbOK
Me.PartNumberCombo.Undo
DoCmd.OpenForm "F_PN_Listing", acNormal, "", "", acAdd, acDialog
DoCmd.Requery "PartNumberCombo"
Case vbCancel
Me.PartNumberCombo.Undo
Cancel = True
End Select
End If
End Sub
but i have two problems
if i select cancel the msgbox the combo is not cleared and i can move to the
next control without getting a warning that the value doesnt match the list
also if i select ok in the msgbox when i close the dialog form and the
requery happens i get a record must be saved first kind of error.
does anybody have a good way to handle this type of operation??
Thanks
Barry
i want to however give the option of if the value is not in the list open up
a form and add it or cancel out and clear the combo box.
heres the my code so far..
Private Sub PartNumberCombo_BeforeUpdate(Cancel As Integer)
Dim lnganswer As String
If Me.PartNumberCombo.ListIndex = -1 Then
lnganswer = MsgBox(Me!PartNumberCombo.Text & " is not in the list would you
like to add it?", vbOKCancel)
Select Case lnganswer
Case vbOK
Me.PartNumberCombo.Undo
DoCmd.OpenForm "F_PN_Listing", acNormal, "", "", acAdd, acDialog
DoCmd.Requery "PartNumberCombo"
Case vbCancel
Me.PartNumberCombo.Undo
Cancel = True
End Select
End If
End Sub
but i have two problems
if i select cancel the msgbox the combo is not cleared and i can move to the
next control without getting a warning that the value doesnt match the list
also if i select ok in the msgbox when i close the dialog form and the
requery happens i get a record must be saved first kind of error.
does anybody have a good way to handle this type of operation??
Thanks
Barry