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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 3061 help with syntax error please

Status
Not open for further replies.

bikerted

Technical User
Nov 7, 2003
221
0
0
GB
Hi All,
The following code for repeating values in one of my forms has served me well, but now it throws up the "too few parameters expected 1" error:
Code:
Private Sub Form_Current()
Dim db As DAO.Database, rst As DAO.Recordset, SQL As String
If Me.NewRecord Then
Set db = CurrentDb
SQL = "SELECT TOP 1 [ReceiptID], LocationSuffixID, AccountID,PayingInNo, [Date Paid In] ,[Date] " & _
"FROM Receipts " & _
"ORDER BY [ReceiptID] DESC;"
Set rst = db.OpenRecordset(SQL, dbOpenDynaset)
If Not (rst.BOF Or rst.EOF) Then
Me!LocationSuffixID.DefaultValue = Nz(rst!LocationSuffixID, "")
Me!AccountID.DefaultValue = Nz(rst!AccountID, "")
Me!PayingInNo.DefaultValue = Chr(34) & Nz(rst!PayingInNo, "") & Chr(34)
Me![Date Paid In].DefaultValue = "#" & Format(Nz(rst![Date Paid In], Date), "yyyy-mm-dd") & "#"
Me![Date].DefaultValue = "#" & Format(Nz(rst![Date], Date), "yyyy-mm-dd") & "#"
Else
End If
Set rst = Nothing
Set db = Nothing
End If
End Sub

MSDN help seems to suggest the SQL syntax are at fault, I've looked and looked (not tha I know what I'm looking at!) but cannot find what has caused this to change. Now I can't open the form without this error which highlights the line:
Code:
Set rst = db.OpenRecordset(SQL, dbOpenDynaset)

Any help would be greatly appreciated, because I'm stumped.

Thanks,

Ted.
 
I think this error may also occur if there's a typo in one/some of the field names.

Since there are no parameters, create the same query in the query builder, then copy/paste rom the SQL view into the code.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top