Error 3061

C

Cyberwolf

When I excute the following code I get an error 3061 "Too few parameters.
Expected 2"

Private Sub Line_Number_AfterUpdate()
'On Error GoTo Line_Number_AfterUpdate_Err

Dim recSet As DAO.Recordset
Dim sqlStmt As String
Dim FOpenedRecSet As Boolean

sqlStmt = "SELECT REF_, Amount FROM CurrentTB WHERE (Line_ =" & Me.[Line
Number] & ");"

Set recSet = CurrentDb().OpenRecordset(sqlStmt)
FOpenedRecSet = True

If (Not (recSet.BOF And recSet.EOF)) Then
Me![Claim Number].Value = recSet.Fields(0).Value
Me!Amount.Value = recSet.Fields(1).Value

End If

'Line_Number_AfterUpdate_Exit:
'If (FOpenedRecSet) Then
' Set recSet = Nothing
' FOpenedRecSet = False
'End If

'Exit Sub

'Line_Number_AfterUpdate_Err:
' MsgBox Err.Description
' Resume Line_Number_AfterUpdate_Exit

End Sub
 
O

Ofer

I can think of two reasons why this error will happen
1. The field name Line_ doesn't exist in the table
2. The Me.[Line Number] doesnt return any value

with 2 I can help, put a code break in the open recordset code (press F9)
when the code stop, check the value of Me.[Line Number]
 
C

Cyberwolf

OK That helped me find that the one side had to be fixed, but I put a watch
on REF_ and got <Expression not defined in Context> With the following code

and also on the [CurrentTB]![Line_] and got
<Accounts Receivable DB can't find the field '|' referred to in your
expression.>


sqlStmt = "SELECT REF_, Amount FROM CurrentTB WHERE ([CurrentTB]![Line_] ="
& Me.[Line Number] & ");"

Ofer said:
I can think of two reasons why this error will happen
1. The field name Line_ doesn't exist in the table
2. The Me.[Line Number] doesnt return any value

with 2 I can help, put a code break in the open recordset code (press F9)
when the code stop, check the value of Me.[Line Number]


--
The next line is only relevant to Microsoft''s web-based interface users.
If I answered your question, please mark it as an answer. It''s useful to
know that my answer was helpful
HTH, good luck


Cyberwolf said:
When I excute the following code I get an error 3061 "Too few parameters.
Expected 2"

Private Sub Line_Number_AfterUpdate()
'On Error GoTo Line_Number_AfterUpdate_Err

Dim recSet As DAO.Recordset
Dim sqlStmt As String
Dim FOpenedRecSet As Boolean

sqlStmt = "SELECT REF_, Amount FROM CurrentTB WHERE (Line_ =" & Me.[Line
Number] & ");"

Set recSet = CurrentDb().OpenRecordset(sqlStmt)
FOpenedRecSet = True

If (Not (recSet.BOF And recSet.EOF)) Then
Me![Claim Number].Value = recSet.Fields(0).Value
Me!Amount.Value = recSet.Fields(1).Value

End If

'Line_Number_AfterUpdate_Exit:
'If (FOpenedRecSet) Then
' Set recSet = Nothing
' FOpenedRecSet = False
'End If

'Exit Sub

'Line_Number_AfterUpdate_Err:
' MsgBox Err.Description
' Resume Line_Number_AfterUpdate_Exit

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top