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
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