Too few parameters error in VBA query

I get the error message: "Too few parameters. Expected 1" when I run the following VBA code.  When I print tdate in the immediate window the query string is: SELECT Account, Symbol FROM [Fidelity Export] WHERE ([Fidelity Export].[Trans Date] > #01/20/09#)

What am I doing wrong?

Thanks!
Function mcrMakeT1()
On Error GoTo mcrMakeT1_Err
    Dim dst As DAO.Database, rstA As DAO.Recordset
    Dim tDate As String, tSQL As String, vI As Long
    
    With CurrentDb
        tDate = Format(.OpenRecordset("qryLastTransDateInHistory")![maxOfTransDate], "mm/dd/yy")
    
'        tSQL = "SELECT [Fidelity Export].ID, [Fidelity Export].Account, [Fidelity Export].[Security Description], " _
'            & "[Fidelity Export].Symbol,  [Fidelity Export].[Trans  Date], [Fidelity Export].[Transaction Description], " _
'            & "[Fidelity Export].Quantity , [Fidelity Export].Amount, [Fidelity Export].Price, [Fidelity Export].Comm, " _
'            & "[Fidelity Export].Fees, [Fidelity Export].[Accrued Interest], [Fidelity Export].[Settlement Date] " _
'            & "FROM [Fidelity Export] " _
'            & "WHERE [Fidelity Export].[Trans Date] > " & tDate
        
        tSQL = "SELECT Account, Symbol FROM [Fidelity Export] WHERE ([Fidelity Export].[Trans Date] > #" & tDate & "#)"
        Set rstA = .OpenRecordset(tSQL)
        
    End With
 
mcrMakeT1_Exit:
    Exit Function
 
mcrMakeT1_Err:
    MsgBox Error$
    Resume mcrMakeT1_Exit
    
 
End Function

Open in new window

jknepperAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Also,  check to be SURE all of the field and table names are spelled correctly, ie no typos.

mx
0
 
GRayLCommented:
Are you sure a date is returned from the query?
0
 
jknepperAuthor Commented:
From the Immediate window:

print tdate
01/20/09
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
If you take the SQL and convert it to SQL you can run in the query designer, do you get a prompt ?

mx
0
 
jmoss111Commented:
The recordset won't like the query parameter. Save the date in a function and use the function in the WHERE.; WHERE([Fidelity Export].[Trans Date] > GetMyDate()).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.