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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for value in listbox

Status
Not open for further replies.

gnt

Technical User
Aug 15, 2002
94
US
Hello-
I want my user to be able to add options to a listbox's underlying query/table. This is no problem, but I want a msgbox to appear if the value already exists. I know this is just a line or two of code but I can't seem to get it right. Here's a bit of what I have to add the record...
Code:
Else
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryAddNewMed"
    MsgBox "Medicine has been added."
    lstMedList.Requery
    Me!txtNewMedName.Value = ""
    txtNewMedName.SetFocus
End If
Thanks in advance!

 
Instead of using the Docmd to run the query, use a QueryDef. You have more control over it and would know what happens.

Use the CreateQueryDef function to create it and look at the properties of the QueryDef to see if it worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top