G
Guest
I am trying to set up an “if†statement to open a form depending on what is
specified on a subform. The main form is “customers†with the subform being
“PetTableâ€. I am trying to bring up one of either a canineshotrecord, or a
felineshotrecord form, depending on what is in the “species†field of the
subform “petTableâ€. Following is the button code that I’ve gotten so far;
however, I get the following error: “Microsoft Office Access can’t find the
field ‘|’ referred to in your expression.â€.
Any help would be appreciated.
Private Sub ShotRecords_Click()
On Error GoTo Err_ShotRecords_Click
Dim Canineshotrecords As String
Dim FelineShotRecords As String
Dim stLinkCriteria As String
stLinkCriteria = "[PetID]=" & "'" & Me![PetID] & "'"
If [subForms]![PetTable].[Species] = "Canine" Then
DoCmd.OpenForm Canineshotrecords, , , stLinkCriteria
Else: DoCmd.OpenForm FelineShotRecords, , , stLinkCriteria
End If
Exit_ShotRecords_Click:
Exit Sub
Err_ShotRecords_Click:
MsgBox Err.Description
Resume Exit_ShotRecords_Click
End Sub
specified on a subform. The main form is “customers†with the subform being
“PetTableâ€. I am trying to bring up one of either a canineshotrecord, or a
felineshotrecord form, depending on what is in the “species†field of the
subform “petTableâ€. Following is the button code that I’ve gotten so far;
however, I get the following error: “Microsoft Office Access can’t find the
field ‘|’ referred to in your expression.â€.
Any help would be appreciated.
Private Sub ShotRecords_Click()
On Error GoTo Err_ShotRecords_Click
Dim Canineshotrecords As String
Dim FelineShotRecords As String
Dim stLinkCriteria As String
stLinkCriteria = "[PetID]=" & "'" & Me![PetID] & "'"
If [subForms]![PetTable].[Species] = "Canine" Then
DoCmd.OpenForm Canineshotrecords, , , stLinkCriteria
Else: DoCmd.OpenForm FelineShotRecords, , , stLinkCriteria
End If
Exit_ShotRecords_Click:
Exit Sub
Err_ShotRecords_Click:
MsgBox Err.Description
Resume Exit_ShotRecords_Click
End Sub