Please Help 
Author Message
 Please Help

I have a need to use a Text box to accept data.  Then go to a ADO Recordset
which has a Text Field (Product ID which is a Access Field within a Table
for which the data type is Text.)

I created a textbox to accept keying in of data.  For example if I wanted to
find any product Id that had the numbers 54 in them anywhere then I would
want the Select statement to use this text input and go out and find what I
need.  Following is code i used.

Dim strSQL1 As String

    strSQL1 = "Select * From Prod2Query " & _
              "Where ProductId Like (%(txtProdId.text)%)"
***********

    With adoProd2Query
        .CommandType = adCmdText
        .RecordSource = strSQL1
        .Refresh
    End With

    Set DataGrid1.DataSource = adoProd2Query

    With DataGrid1
        .AllowAddNew = True
        .AllowUpdate = True
        .Refresh
    End With

*********** This seems to be where the problem happens.  Does not like my
Where and Like combination.


Thanks



Thu, 17 May 2001 03:00:00 GMT  
 Please Help
Bob,

You need to write the SQL statement like this:

    strSQL1 = "Select * From Prod2Query " & _
              "Where ProductId Like (%" & txtProdId.text & "%)"

The way you had it, VB as including '(txtProdId.text)' in the SQL statement
as a literal value.  The above statement will send the data in the textbox.

HTH,

Mike

Quote:

>I have a need to use a Text box to accept data.  Then go to a ADO Recordset
>which has a Text Field (Product ID which is a Access Field within a Table
>for which the data type is Text.)

>I created a textbox to accept keying in of data.  For example if I wanted
to
>find any product Id that had the numbers 54 in them anywhere then I would
>want the Select statement to use this text input and go out and find what I
>need.  Following is code i used.

>Dim strSQL1 As String

>    strSQL1 = "Select * From Prod2Query " & _
>              "Where ProductId Like (%(txtProdId.text)%)"
>***********

>    With adoProd2Query
>        .CommandType = adCmdText
>        .RecordSource = strSQL1
>        .Refresh
>    End With

>    Set DataGrid1.DataSource = adoProd2Query

>    With DataGrid1
>        .AllowAddNew = True
>        .AllowUpdate = True
>        .Refresh
>    End With

>*********** This seems to be where the problem happens.  Does not like my
>Where and Like combination.


>Thanks



Fri, 18 May 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

2. PLEASE HELP PLEASE HELP PLEASE HELP

3. Please Help...Crystal Reports..Please Help

4. PLEASE HELP... PLEASE HELP... PLEASE HELP...

5. Please Please PLEASE HELP!!!!!

6. Please please please, help me :-)

7. Please, please, please help!!

8. Cloning problem -- please please please help

9. Please, please, please, help!

10. DATAbase Printing PLEASE, PLEASE Help me - please?

11. DATAbase Printing - PLEASE, PLEASE Help me - please?

12. Please, Please, Please,Help craxdrt.dll

 

 
Powered by phpBB® Forum Software