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

Not in List problem with query source

Status
Not open for further replies.

Dophia

Technical User
Jul 26, 2004
263
CA
Hi Everyone: I need advice on a form and a field with a drop down list.

I have a form where the user chooses a item from a drop down list. The list is based on a query which has two fields. One field is a "medication" and the second field is a check box named "disable". So, any item that has a check in the check box has been disabled and it is not available to be chosen. But there is an Event "Not in List". It works well, until the user chooses an item that has been disabled. They get an error that it would cause duplicate item and can't be added. I cannot figure out what is wrong. Is the original setup of having a "disable" option the problem? Or can I add an error message that tells them that the item is not available to be chosen or added, since it is disabled?


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


Dim strTmp As String

'Get confirmation that this is not just a spelling error.
strTmp = "Add '" & NewData & "' as a new medication?"
If MsgBox(strTmp, vbYesNo + vbDefaultButton2 + vbQuestion, "Not in list") = vbYes Then

'Append the NewData as a record in the Categories table.
strTmp = "INSERT INTO LkkpHealth_Meds ( Medication_Name ) " & _
"SELECT """ & NewData & """ AS Medication_Name;"

DBEngine(0)(0).Execute strTmp, dbFailOnError

Response = acDataErrContinue

End If
End Sub

Thanks, Sophia

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top