Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error - form button (report) 1

Status
Not open for further replies.

ProtegeV2

Technical User
Sep 9, 2004
40
0
0
CA
Can you help me fix a form button? My On_Click is below. I am trying to run a report based on the information in the displayed record. i.e., with record 3368 displayed, I receive the message: syntax error in date in query expression '(Docket #=3368'.

Note that the report worked when I had the user enter the criteria [Enter Docket #] but I've removed this WHERE clause.

Here is the SQL - is the inner join causing the problem??
Thanks.

SELECT [Project Expenses Table].[Invoice ID], [Project Expenses Table].[Invoice Amount], [Project Expenses Table].[Invoice Date], [Project Expenses Table].[Docket #], [Project Expenses Table].[Docket #], [Project Expenses Table].[Description of Invoice], [Project Request Table].[Project Title], [Project Request Table].Status, [Project Request Table].Expenses, [Project Request Table].[Tracking Estimate], [Project Expenses Table].[Person Submitting Invoice], [Project Request Table].[Date of Request], [Project Request Table].[Budget Amount], [Project Request Table].[Cost Centre], [Project Request Table].[Network Number]
FROM [Project Request Table] INNER JOIN [Project Expenses Table] ON [Project Request Table].[Docket #] = [Project Expenses Table].[Docket #]
ORDER BY [Project Expenses Table].[Docket #];

Here's my On_Click:
Private Sub Command98_Click()
On Error GoTo Err_Command98_Click

Dim stDocName As String
Dim strWhere As String

strWhere = "Docket #=" & Me.txtDocket
stDocName = "rptDocketExpenses"
DoCmd.OpenReport stDocName, acPreview, , strWhere

Exit_Command98_Click:
Exit Sub

Err_Command98_Click:
MsgBox Err.Description
Resume Exit_Command98_Click

End Sub
 
Field names containing special characters or spaces need to be surrounded with [brackets]:

[tt]strWhere = "[Docket #]=" & Me.txtDocket[/tt]

- the message relating to Date, is probably because hash (#) is date delimiter, so it expects a date.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top