Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo box (limit to list) allows null values ?

Status
Not open for further replies.

danno28

Programmer
Sep 5, 2002
8
GB
Hi,

I have a combo box which has 'limit to list' selected. When I open my form i populate the list from a piece of code, then set the combo box to the first item in the list. My problem is when i try to use the combo box....it works fine when i enter an item which isnt on the list (pops up system message), but when I enter a null value it accepts it ? is it possbile to get the same 'the text you entered isn't an item in the list' message ?

also, is it possbile to have 'limit to list' selected, but to use my own message? i've put a message in the 'not in list' event but now get my message and the system message. i've tried set warnings false, but this doesnt seem to work.

thank
Dan
 
Hi, Dan. Here's a couple of examples. The first one is from my purchase order app and opens a form to add a new vendor. The second example allows the user to enter a new customer on the work order form immediately without opening a separate customer form. Maybe you can use something here.


Example 1:

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

Dim intNewVendor As Integer, intTruncateName As Integer, _
strMsgBoxCaption As String, intMsgDialog As Integer

strMsgBoxCaption = "Vendor Not In List"
intMsgDialog = vbYesNo + vbQuestion + vbDefaultButton1
intNewVendor = MsgBox("Do you want to add a new vendor?", intMsgDialog, _
strMsgBoxCaption)

If intNewVendor = vbYes Then
' Remove vendor from the Vendor combo box so control can be requeried
' when user returns to form.

DoCmd.RunCommand acCmdUndo



' Open AddNewVendor form.
DoCmd.OpenForm "frmAddNewVendor", acNormal, , , acAdd, acDialog, _
NewData

'Continue without displaying default error message and add new value
'to the combo box.

Response = acDataErrAdded

End If

End Sub


Example 2:

Private Sub ContactID_NotInList(NewData As String, Response As Integer)
On Error GoTo HandleErr

If MsgBox("Would you like to add this contact to the database?", _
vbYesNo + vbQuestion, "Contact not in JSJ database") = vbYes Then
Response = AddToList("Contacts", "ContactName", NewData)
Else
Response = acDataErrDisplay
End If


ExitHere:
Exit Sub

HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, vbOKOnly, _
"JSJ, Inc."
End Select
Resume ExitHere
Resume

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top