Run-Time Error, what's wrong?

momar
momar used Ask the Experts™
on
Why do I get the following error in VB when I run this code?  Heh I haven't done vb in a very long time, so the answer may be simple....

[ODBC Microsoft Access Driver]Too Few Parameters
Expected 1

Code:

 sqlStringInventory = "Select PartNumber, PartName, Quanitity, Price, DatePurchased, Description From Inventory Where PartNumber = '" & txtPartNum.Text & "'"
     Connect_Inventory (sqlStringInventory)
     Set dgInventory.DataSource = rsInventory

Public Sub Connect_Inventory(sqlString)
    Set db1 = New ADODB.Connection
    db1.Open "Provider=MSDASQL;DSN=AdinSystem"
    Set rsInventory = New ADODB.Recordset
    rsInventory.Open sqlString, db1, adOpenKeyset, adLockPessimistic
End Sub

Any help would be great, thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
HI Momar,

What is dgInventory?  I don't see the declaration.

Author

Commented:
It's a DataGrid, just wanted to display the results in a DataGrid.
try pasting the SQL into the Access query builder, and see what you get.  The error USUALLY indicates that a field name in mis-spelled.

my guess is that PartNumber is defined as a numeric on the DB, but you are passing a string in.

Change to:

sqlStringInventory = "Select PartNumber, PartName, Quanitity, Price, DatePurchased, Description From Inventory Where PartNumber = " & val(txtPartNum.Text)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial