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

Error number 3061, when retrieving data from access 1

Status
Not open for further replies.

newprogamer

Programmer
Sep 22, 2004
107
US
I am receiving an error. Error number 3061. Too few parameters. I don't quite understand the irow or if this is the best way to retrieve data from access and display the results for the user. But I'm trying it. I would like the user to be able to search for the Manufacturer, model, or Quoters' name and see a list and then select the file he/she needs.

My code is below. Please help!

***********************************************************
Private Sub WriteToDB(strQuoter, strInitials, strSequence, strManufacturer, strModel, strFileName)

'Write Filename to access database
Dim db As Database
Dim Rs As Recordset

Set db = OpenDatabase("C:\Quotes\quoteDB.mdb")

' open the database
Set Rs = db.OpenRecordset("tblFileName", dbOpenTable)

With Rs
.AddNew 'create a new record into the database

' add values to each field in the record
Rs("Quoter") = strQuoter
Rs("Initials") = strInitials
Rs("Sequence") = strSequence
Rs("Manufacturer") = strManufacturer
Rs("Model") = strModel
Rs("Name") = strFileName

.Update 'writes record to the database
End With
End Sub
'**********************************************
Private Sub cmdSearch_Click()
Dim db As Database
Dim Rs As Recordset
Dim irow As String

On Error GoTo errhandler:

'open the database
Set db = OpenDatabase("C:\Quotes\quoteDB.mdb")

'open the RS and search for contents in the cbo box
Set Rs = db.OpenRecordset("SELECT * FROM tblFileName WHERE Manufacturer = " & cboManufacturer.Text)

Rs.MoveFirst
irow = 8
Do While Not Rs.EOF
Cells(irow, 1) = Rs("Quoter")
Cells(irow, 2) = Rs("Initials")
Cells(irow, 3) = Rs("DateQuoted") 'date generated by access
Cells(irow, 4) = Rs("Sequence")
Cells(irow, 5) = Rs("Manufacturer")
Cells(irow, 6) = Rs("Model")
Cells(irow, 7) = Rs("Name")

irow = irow + 1
Rs.MoveNext
Loop

errhandler:
MsgBox Err.Number & " " & Err.Description & "."

End Sub
 
Is there a parameter or a custom function in the access query?
 
Hi newprogamer,

Where do you get the error?

One thing which looks wrong is ..

[tt] Set Rs = db.OpenRecordset("SELECT * FROM tblFileName WHERE Manufacturer = " & cboManufacturer.Text)[/tt]

.. shouldn't the text be in quotes? ...

[tt] Set Rs = db.OpenRecordset("SELECT * FROM tblFileName WHERE Manufacturer = [highlight][red]'[/red][/highlight]" & cboManufacturer.Text [highlight][red] & "'"[/red][/highlight])[/tt]

I think this could trigger the message you quote.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Thanks so much for the response!
TonyJollans, that resolved the Error number 3061.

ETID, I'm not sure what the answer is to your question.

I want the user to click the Search command button, choose their search criteria (manufacturer for now), let the code display the results, let the user click on the row that contains the information he would like to view, and then open up "Name". "Name" is a field in access that contains the name of the word document I would like to open. Any help would be greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top