Single instance on a Report

Nick Druce

Registered User.
Local time
Today, 08:47
Joined
Mar 2, 2005
Messages
18
I have created a form, when all the feilds are feild in I want to be able to click a button and have the report print out the details for that instance on the form. The code i have is below. When I click the buttojn i get the error

Syntax Error (Missing operator) in Query expression'(childsname=tom)'


Private Sub ShowReport_Click()
On Error GoTo Err_ShowReport_Click

DoCmd.OpenReport "ChildDetails", acViewPreview, , "Childs Name = " & Forms![Child Details Query]![Childs Name]

Exit_ShowReport_Click:
Exit Sub

Err_ShowReport_Click:
MsgBox Err.Description
Resume Exit_ShowReport_Click

End Sub
 
If childs name is a string or text field then try including a single quote as follows:

DoCmd.OpenReport "ChildDetails", acViewPreview, , "Childs Name = '" & Forms![Child Details Query]![Childs Name] & "'"
 
I Still get the same error

Syntax Error (Missing operator) in Query expression'(childsname=tom)'
 
Make sure that you get both of the single quotes in - theres one after the equals (before the double quote) and one attaced on the end (between double quotes) - copy and paste this line

DoCmd.OpenReport "ChildDetails", acViewPreview, , "Childs Name = '" & Forms![Child Details Query]![Childs Name] & "'"

Good luck
 
Nick,

Try something like this

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "ChildDetails"
strLinkCriteria = "[Childs Name] = Forms![Child Details Query]![Childs Name]"

DoCmd.OpenReport strDocName, acViewPreview, , strLinkCriteria

hth,
Michael
 

Users who are viewing this thread

Back
Top Bottom