A
Anthony Dowd
Hi
I have two forms which are related by a field called "PatientID". The first
form (Patient Details) has a command button on it that opens the other form
(Operation) when clicked. Below is the code for this form.
***************************************************
Private Sub NextPage2_Click()
On Error GoTo Err_NextPage2_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Operation"
stLinkCriteria = "[PatientID]=" & Me![PatientID]
DoCmd.Save acForm, "Patient Details"
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "You can not open the next form when there are no records in
this one"
Else
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Maximize
End If
Exit_NextPage2_Click:
Exit Sub
Err_NextPage2_Click:
MsgBox Err.Description
Resume Exit_NextPage2_Click
End Sub
**************************************************
Other information:
1. Row Source of Combo Box PatientID in tblOperation
SELECT [Patient Details].[PatientID] FROM [Patient Details]; .
2. Row source of PatientId in Operation Form
SELECT [Patient Details].[PatientID] FROM [Patient Details];
3. Default value of PatientID in Operation Form
=DMax("[PatientID]","Patient Details")
So...When the command button on the first form (Patient Details) is clicked,
the second form (ie operation) opens at the correct "PatientID" when:
1. there is an existing record in the second form.
2. I enter the data in the first form and immediately open the second form.
However...The second form does not open at the correct PatientID when I
enter several records in the first form without going to the second form.
This is a requirement of the application. When I do go back to enter the
data in the second form for a particular patient, this form opens at
PatientID = DMax instead of the correct PatientID. If I delete the DMax
function in the default value of PatientID in the Operation Form, then I get
an error in PatientID on the Operation form and must select the value for
PatientID. I want this value to be selected automatically.
How can i open the Operation form at the correct PatientId, even when
entering several records in the first form then going back to enter related
records in the second form some time later?
Thanks in advance
Anthony
I have two forms which are related by a field called "PatientID". The first
form (Patient Details) has a command button on it that opens the other form
(Operation) when clicked. Below is the code for this form.
***************************************************
Private Sub NextPage2_Click()
On Error GoTo Err_NextPage2_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Operation"
stLinkCriteria = "[PatientID]=" & Me![PatientID]
DoCmd.Save acForm, "Patient Details"
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "You can not open the next form when there are no records in
this one"
Else
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Maximize
End If
Exit_NextPage2_Click:
Exit Sub
Err_NextPage2_Click:
MsgBox Err.Description
Resume Exit_NextPage2_Click
End Sub
**************************************************
Other information:
1. Row Source of Combo Box PatientID in tblOperation
SELECT [Patient Details].[PatientID] FROM [Patient Details]; .
2. Row source of PatientId in Operation Form
SELECT [Patient Details].[PatientID] FROM [Patient Details];
3. Default value of PatientID in Operation Form
=DMax("[PatientID]","Patient Details")
So...When the command button on the first form (Patient Details) is clicked,
the second form (ie operation) opens at the correct "PatientID" when:
1. there is an existing record in the second form.
2. I enter the data in the first form and immediately open the second form.
However...The second form does not open at the correct PatientID when I
enter several records in the first form without going to the second form.
This is a requirement of the application. When I do go back to enter the
data in the second form for a particular patient, this form opens at
PatientID = DMax instead of the correct PatientID. If I delete the DMax
function in the default value of PatientID in the Operation Form, then I get
an error in PatientID on the Operation form and must select the value for
PatientID. I want this value to be selected automatically.
How can i open the Operation form at the correct PatientId, even when
entering several records in the first form then going back to enter related
records in the second form some time later?
Thanks in advance
Anthony