Error

G

Guest

Hi,

I got help earlier, but I got an error neither of us undersood
The error is:
Run-time error: '3061'
too few parameters. Expected 5

My Code looks like this:
Private Sub Additive_Click()
Dim rst As Recordset
Dim strSQL As String
Dim strAdditive As String

strAdditive = "Me!Additive"

strSQL = "SELECT * FROM [tblPropellant Query]" & " WHERE AD1NAM = '" &
strAdditive _
& "' Or AD2NAM = '" & strAdditive & "' Or AD3NAM = '" & strAdditive & "'
Or AD4NAM = '" _
& strAdditive & "' Or AD5NAM = '" & strAdditive & "';"

Set rst = CurrentDb.OpenRecordSet(strSQL)

If rst.RecordCount = 0 Then
'No Matches
Else
rst.MoveLast
rst.MoveFirst
End If

End Sub

and this part is highlighted:
Set rst = CurrentDb.OpenRecordSet(strSQL)
I would apreciate any help.
-James
 
D

Duane Hookom

Try:
strAdditive = Me!Additive
I don't think you want to look in the fields for the value "Me!Additive".
 
G

Guest

Duane,

I get the same error even without the quotes, but i found out this code wont
do exactly what I want it to anyway, I would like it to search multiple
fields, AD1NAM, AD2NAM, ect. for one user selected criteria and open all of
the Forms for it, not the table.
If you know how to do that I would aprieciate it.

-James
Duane Hookom said:
Try:
strAdditive = Me!Additive
I don't think you want to look in the fields for the value "Me!Additive".

--
Duane Hookom
MS Access MVP


James said:
Hi,

I got help earlier, but I got an error neither of us undersood
The error is:
Run-time error: '3061'
too few parameters. Expected 5

My Code looks like this:
Private Sub Additive_Click()
Dim rst As Recordset
Dim strSQL As String
Dim strAdditive As String

strAdditive = "Me!Additive"

strSQL = "SELECT * FROM [tblPropellant Query]" & " WHERE AD1NAM = '" &
strAdditive _
& "' Or AD2NAM = '" & strAdditive & "' Or AD3NAM = '" & strAdditive &
"'
Or AD4NAM = '" _
& strAdditive & "' Or AD5NAM = '" & strAdditive & "';"

Set rst = CurrentDb.OpenRecordSet(strSQL)

If rst.RecordCount = 0 Then
'No Matches
Else
rst.MoveLast
rst.MoveFirst
End If

End Sub

and this part is highlighted:
Set rst = CurrentDb.OpenRecordSet(strSQL)
I would apreciate any help.
-James
 
D

Duane Hookom

I would normalize the tables so that you don't have repeating columns (etc).

Your statement of "open all of the Forms for it" makes very little sense.

--
Duane Hookom
MS Access MVP


James said:
Duane,

I get the same error even without the quotes, but i found out this code
wont
do exactly what I want it to anyway, I would like it to search multiple
fields, AD1NAM, AD2NAM, ect. for one user selected criteria and open all
of
the Forms for it, not the table.
If you know how to do that I would aprieciate it.

-James
Duane Hookom said:
Try:
strAdditive = Me!Additive
I don't think you want to look in the fields for the value "Me!Additive".

--
Duane Hookom
MS Access MVP


James said:
Hi,

I got help earlier, but I got an error neither of us undersood
The error is:
Run-time error: '3061'
too few parameters. Expected 5

My Code looks like this:
Private Sub Additive_Click()
Dim rst As Recordset
Dim strSQL As String
Dim strAdditive As String

strAdditive = "Me!Additive"

strSQL = "SELECT * FROM [tblPropellant Query]" & " WHERE AD1NAM = '"
&
strAdditive _
& "' Or AD2NAM = '" & strAdditive & "' Or AD3NAM = '" & strAdditive
&
"'
Or AD4NAM = '" _
& strAdditive & "' Or AD5NAM = '" & strAdditive & "';"

Set rst = CurrentDb.OpenRecordSet(strSQL)

If rst.RecordCount = 0 Then
'No Matches
Else
rst.MoveLast
rst.MoveFirst
End If

End Sub

and this part is highlighted:
Set rst = CurrentDb.OpenRecordSet(strSQL)
I would apreciate any help.
-James
 
G

Guest

Sorry, I meant open one form where there is more than one record, the arrow
butons on the bottom right of the form cycle through the different records.
but I found out what was wrong thanks any way

-James

Duane Hookom said:
I would normalize the tables so that you don't have repeating columns (etc).

Your statement of "open all of the Forms for it" makes very little sense.

--
Duane Hookom
MS Access MVP


James said:
Duane,

I get the same error even without the quotes, but i found out this code
wont
do exactly what I want it to anyway, I would like it to search multiple
fields, AD1NAM, AD2NAM, ect. for one user selected criteria and open all
of
the Forms for it, not the table.
If you know how to do that I would aprieciate it.

-James
Duane Hookom said:
Try:
strAdditive = Me!Additive
I don't think you want to look in the fields for the value "Me!Additive".

--
Duane Hookom
MS Access MVP


Hi,

I got help earlier, but I got an error neither of us undersood
The error is:
Run-time error: '3061'
too few parameters. Expected 5

My Code looks like this:
Private Sub Additive_Click()
Dim rst As Recordset
Dim strSQL As String
Dim strAdditive As String

strAdditive = "Me!Additive"

strSQL = "SELECT * FROM [tblPropellant Query]" & " WHERE AD1NAM = '"
&
strAdditive _
& "' Or AD2NAM = '" & strAdditive & "' Or AD3NAM = '" & strAdditive
&
"'
Or AD4NAM = '" _
& strAdditive & "' Or AD5NAM = '" & strAdditive & "';"

Set rst = CurrentDb.OpenRecordSet(strSQL)

If rst.RecordCount = 0 Then
'No Matches
Else
rst.MoveLast
rst.MoveFirst
End If

End Sub

and this part is highlighted:
Set rst = CurrentDb.OpenRecordSet(strSQL)
I would apreciate any help.
-James
 

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