Eric the Viking
Registered User.
- Local time
- Today, 00:01
- Joined
- Sep 20, 2012
- Messages
- 70
Seasons Greetings All
I have a minor niggle I am struggling to iron out. We have a database recording patient records and I am trying to stop people including me....!!! entering new records when the record already exists in the database.....it seems it is easily done after a hard day at the coal face!
I have an unbound txtbox named TextSurname (which will search on either surname or record number to populates a list box so exiisting records can be checked before hitting the enter new record button.
In the new record buttons code I have the following:
Private Sub OpeningFormPtDetails_Click()
On Error GoTo Err_ OpeningFormPtDetails _Click
Dim stDocName As String
Dim stLinkCriteria As String
If Me.TextSurname = "" Then
Me. OpeningFormPtDetails.Enabled = False
Else: Me. OpeningFormPtDetails.Enabled = True
End If
stDocName = "frm-patient details"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Exit_opening_form_pt_details_Click:
Exit Sub
Err_opening_form_pt_details_Click:
' MsgBox Err.Description
MsgBox "Check if the patient record already exists before entering a new patient", vbCritical
Resume Exit_ OpeningFormPtDetails _Click
End Sub
which is supposed to disable the button and encourage the user to check if the record exists first. It works fine except on opening the form containing the controls when the button will fire once to open the new record form afer which it is disabled until the TextSurname field has been filled.
Any ideas would be much appreciated.
Best
Eric
I have a minor niggle I am struggling to iron out. We have a database recording patient records and I am trying to stop people including me....!!! entering new records when the record already exists in the database.....it seems it is easily done after a hard day at the coal face!
I have an unbound txtbox named TextSurname (which will search on either surname or record number to populates a list box so exiisting records can be checked before hitting the enter new record button.
In the new record buttons code I have the following:
Private Sub OpeningFormPtDetails_Click()
On Error GoTo Err_ OpeningFormPtDetails _Click
Dim stDocName As String
Dim stLinkCriteria As String
If Me.TextSurname = "" Then
Me. OpeningFormPtDetails.Enabled = False
Else: Me. OpeningFormPtDetails.Enabled = True
End If
stDocName = "frm-patient details"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Exit_opening_form_pt_details_Click:
Exit Sub
Err_opening_form_pt_details_Click:
' MsgBox Err.Description
MsgBox "Check if the patient record already exists before entering a new patient", vbCritical
Resume Exit_ OpeningFormPtDetails _Click
End Sub
which is supposed to disable the button and encourage the user to check if the record exists first. It works fine except on opening the form containing the controls when the button will fire once to open the new record form afer which it is disabled until the TextSurname field has been filled.
Any ideas would be much appreciated.
Best
Eric