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

showing only matched records in datagrid

Status
Not open for further replies.

lalee5

Technical User
Oct 20, 2002
70
0
0
US
Dear experts out there, Please help!!

I have 2 datagrids and a textbox. I want the datagrids to show only records matching the product number that I type into the textbox.

I use a code from another thread below but it did not work.
I put the code behind the productno change event:

The following code is for the first datagrid. I figure if I can get one to work it would be a piece of cake for the second one. the productno.text is unbound.

Dim MyRS As ADODB.Recordset
Dim MySQLString As String

Set MyRS = New ADODB.Recordset
MyRS.CursorLocation = adUseClient
MySQLString = "SELECT * FROM tpurchase WHERE purproductno = productno.text"
MyRS.Open MySQLString, MyConnection, adOpenDynamic, adLockOptimistic

Set DataGrid1.DataSource = MyRS

it is crashing at "MyRS.Open MySQLString, MyConnection, adOpenDynamic, adLockOptimistic" with the follwoing error

"Arguments of the wrong type, are out of acceptable range, or are in conflict with one another"

thanks for your help in advance.


Kay
 
Hi,
First of all ur query string is not proper, i mean u r not concatinating Productno well with other string. anyway this might not be the cause of error.

Debug ur porgramme for couple of things:

1) Ur connection is open?
2) and contants u r using like adOpenDynamic and adLockOptimistic are containing correct values.

i feel ur connection is not open for some reasons.

Good Luck
 
To start with, try:
[tt]
MySQLString = "SELECT * FROM tpurchase WHERE purproductno = " & productno.text
[/tt]
instead of what you currently have.
 

You obviously meant to correct lalee5 like this:


MySQLString = "SELECT * FROM tpurchase WHERE purproductno = '" & productno.text & "'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top