newprogamer
Programmer
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
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