Hi,
I have a field call MRN. The property is text and max length is 8. In the data entry form, I have it as a combo box names cboMRN. I would like to force user to enter exactly 8 digits, if user enter less or more than 8, I won't allow user to add.
Here is my code in the "NOT IN LIST" feature. (If user enter a new MRN, it'll prompt user to add new MRN, if user enter an exiting MRN, it'll show the record info)
I tried to set the INPUT MASK as =000000000 in the property of the cboMRN to force user to enter 8 digits, it works but then it unable the search in the combo box, when I type the MRN into the cboMRN box, it won't do search.
Can anyone please help?
thanks!
I have a field call MRN. The property is text and max length is 8. In the data entry form, I have it as a combo box names cboMRN. I would like to force user to enter exactly 8 digits, if user enter less or more than 8, I won't allow user to add.
Here is my code in the "NOT IN LIST" feature. (If user enter a new MRN, it'll prompt user to add new MRN, if user enter an exiting MRN, it'll show the record info)
Code:
Private Sub cboID_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Response = acDataErrContinue
strMsg = "The Medical Record Number'" & NewData & "' you selected is not in the list. "
strMsg = strMsg & "Do you want to add it?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add New Patient?") = vbYes Then
DoCmd.GoToRecord , , acNewRec
[txtMEDREC] = NewData
[txtMEDREC].Enabled = True
[txtPATFNM].Enabled = True
[txtPATLNM].Enabled = True
[txtPATSEX].Enabled = True
txtPATLNM.SetFocus
cmdAddNewPtAccount.Enabled = True
Else
Response = acDataErrContinue
End If
End Sub
Can anyone please help?
thanks!
Comment