I
iain
Hi,
I'm trying to get a query to run based on where a record's
Contact ID matches that of the current record in a form.
I've got working to run a report based on the contact ID,
ie bring up a report listing of developments for that of
the current contact, using the code :
Private Sub Command45_Click()
On Error GoTo Err_Command45_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Glasgow Developments by Contact"
stLinkCriteria = "[Contact ID]=" & Me![Contact ID]
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
Exit_Command45_Click:
Exit Sub
Err_Command45_Click:
MsgBox Err.Description
Resume Exit_Command45_Click
End Sub
The code I currently have to try to do the same thing, but
running the query, is :
Private Sub Command48_Click()
On Error GoTo Err_Command48_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Glasgow Development by Contact Email"
stLinkCriteria = "[Contact ID]=" & Me![Contact ID]
DoCmd.OpenQuery stDocName, acNormal, acEdit, ,
stLinkCriteria
Exit_Command48_Click:
Exit Sub
Err_Command48_Click:
MsgBox Err.Description
Resume Exit_Command48_Click
End Sub
but am just getting the error message :
Compile Error :
Wrong number of arguments or invalid property assignment.
Any ideas on where to change the code to ge this to work?
Cheers,
Iain
I'm trying to get a query to run based on where a record's
Contact ID matches that of the current record in a form.
I've got working to run a report based on the contact ID,
ie bring up a report listing of developments for that of
the current contact, using the code :
Private Sub Command45_Click()
On Error GoTo Err_Command45_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Glasgow Developments by Contact"
stLinkCriteria = "[Contact ID]=" & Me![Contact ID]
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
Exit_Command45_Click:
Exit Sub
Err_Command45_Click:
MsgBox Err.Description
Resume Exit_Command45_Click
End Sub
The code I currently have to try to do the same thing, but
running the query, is :
Private Sub Command48_Click()
On Error GoTo Err_Command48_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Glasgow Development by Contact Email"
stLinkCriteria = "[Contact ID]=" & Me![Contact ID]
DoCmd.OpenQuery stDocName, acNormal, acEdit, ,
stLinkCriteria
Exit_Command48_Click:
Exit Sub
Err_Command48_Click:
MsgBox Err.Description
Resume Exit_Command48_Click
End Sub
but am just getting the error message :
Compile Error :
Wrong number of arguments or invalid property assignment.
Any ideas on where to change the code to ge this to work?
Cheers,
Iain