View Full Version : Single instance on a Report


Nick Druce
03-08-2005, 01:38 AM
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

Valerie
03-08-2005, 02:40 AM
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] & "'"

Nick Druce
03-08-2005, 04:40 AM
I Still get the same error

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

Valerie
03-08-2005, 04:50 AM
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

Ukraine82
03-08-2005, 05:03 AM
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