Unanswered: Only enter existing values in text field
I have a form (only shows Patient Name) with subform that shows (BillID, PatientID, Sickness, Prescribtion, DoctorIDand Doctor Name) -
Patient Name and Doctor Name are based on other tables (Patient & Doctor)
I used combobox for the Patient Name so that I can only select from values already exist in table Patient-so that I can't enter names, only select...untill now everything is okay
However, with Doctor Name-, I want to be able to write one of the doctor names that already exist, so I do NOT want new names to be entered....how can I do this without using a combobox? coz whenever I write a new name it is entered in the Doctor table..
And IF i need to use combobox, how can I change the current text box to combobox with wizard? I know that I have to go to Format --> Change >combobox, but I want to see the wizard to guide me ... or how can i change properties so that it selects values I want
You could use this (adapt the names to those of your database):
Private Sub Text_DoctorName_BeforeUpdate(Cancel As Integer)
If DCount("[Doctor Name]", "Doctor", "[Doctor Name] = '" & Me.Text_DoctorName.Value & "'") = 0 Then
MsgBox "This doctor name does not exist.", vbInformation, "Not found"
Cancel = True
Hi I would like to thank you for helping again, it works fine..
I starting wondering, is there something wrong with my database relationship?
because I noticed even when I enter a new doctor ID it accepts it, should a correct relationship bans entering a new doctor id in a bill table??