A
Anthony
Hello
First problem:
I have a form called "Patient Details" with a command button, which is
supposed to act as a next button and open a second form called "Indication"
at a record with the same ID number (i.e., PatientID) as in the first form.
The form opens ok, but not at the record with the same PatientID as in the
previous form. The code used for this command button is:
Private Sub NextPage2_Click()
On Error GoTo Err_NextPage2_Click
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Indication"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Exit_NextPage2_Click:
Exit Sub
Err_NextPage2_Click:
MsgBox Err.Description
Resume Exit_NextPage2_Click
End Sub
Also, the Row Source of PatientID in the "Indication" form is: SELECT
[Patient Details].[PatientID] FROM [Patient Details];
Second problem:
On the second form, "Indication", I also have a command button that is
supposed to act as a "back" button and take the user back to the "Patient
Details" form, again to the record with the same PatientID.
The correct form opens, but an error message appears:
"The expression you entered refers to an object that is closed or doesn't
exist" and the form doesn't open at the record with the PatientID that was
active on the previous form. The code for this command button is:
Private Sub Command17_Click()
On Error GoTo Err_Command17_Click
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Patient Details"
DoCmd.OpenForm stDocName, , , stLinkCriteria
stLinkCriteria = "[PatientID]=" & Me![PatientID]
Exit_Command17_Click:
Exit Sub
Err_Command17_Click:
MsgBox Err.Description
Resume Exit_Command17_Click
End Sub
Any help with where I am going wrong here would be greatly appreciated.
Thanks in advance
Anthony
First problem:
I have a form called "Patient Details" with a command button, which is
supposed to act as a next button and open a second form called "Indication"
at a record with the same ID number (i.e., PatientID) as in the first form.
The form opens ok, but not at the record with the same PatientID as in the
previous form. The code used for this command button is:
Private Sub NextPage2_Click()
On Error GoTo Err_NextPage2_Click
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Indication"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Exit_NextPage2_Click:
Exit Sub
Err_NextPage2_Click:
MsgBox Err.Description
Resume Exit_NextPage2_Click
End Sub
Also, the Row Source of PatientID in the "Indication" form is: SELECT
[Patient Details].[PatientID] FROM [Patient Details];
Second problem:
On the second form, "Indication", I also have a command button that is
supposed to act as a "back" button and take the user back to the "Patient
Details" form, again to the record with the same PatientID.
The correct form opens, but an error message appears:
"The expression you entered refers to an object that is closed or doesn't
exist" and the form doesn't open at the record with the PatientID that was
active on the previous form. The code for this command button is:
Private Sub Command17_Click()
On Error GoTo Err_Command17_Click
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Patient Details"
DoCmd.OpenForm stDocName, , , stLinkCriteria
stLinkCriteria = "[PatientID]=" & Me![PatientID]
Exit_Command17_Click:
Exit Sub
Err_Command17_Click:
MsgBox Err.Description
Resume Exit_Command17_Click
End Sub
Any help with where I am going wrong here would be greatly appreciated.
Thanks in advance
Anthony