dbTalk Databases Forums  

using the result of a text box as input to SQL

comp.database.ms-access comp.database.ms-access


Discuss using the result of a text box as input to SQL in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Doug
 
Posts: n/a

Default using the result of a text box as input to SQL - 03-03-2004 , 11:58 PM






Hi,

I am using a form with some text boxes to populate some VBA code that
calls up a query. Using MS Access 2000.

I am using would like my query to read something like:
SELECT * FROM [newvars] where Label like *parm* ;"

.... and label is the result of some options, and parm is the result of
a text box input.

Any help appreciated.

Doug

Reply With Quote
  #2  
Old   
Ray
 
Posts: n/a

Default Re: using the result of a text box as input to SQL - 03-04-2004 , 07:50 AM






queanbeyan (AT) hotmail (DOT) com (Doug) wrote in message news:<d72455ac.0403032158.141df291 (AT) posting (DOT) google.com>...
Quote:
Hi,

I am using a form with some text boxes to populate some VBA code that
calls up a query. Using MS Access 2000.

I am using would like my query to read something like:
SELECT * FROM [newvars] where Label like *parm* ;"

... and label is the result of some options, and parm is the result of
a text box input.

Any help appreciated.

Doug
Hello Doug,

Perhaps you can just have the criteria field of your query,
for the field involved, source the text box on your form like:

[Forms]![SourceFormNameHere]![txtParameter]

This will run the query sourcing your text box on the relevant
form. This can be done for each field in your query that needs
to soure your main form.

Regards,

Ray


Reply With Quote
  #3  
Old   
Doug
 
Posts: n/a

Default Re: using the result of a text box as input to SQL - 03-04-2004 , 09:53 PM



Ray,

Thanks for your help.

This almost works however I have a series of parameters and conditions
that I need to apply.

eg: dogs and cats and birds and bears

I have a select case routine in vba that looks at 2 options boxes and
then the text boxes and then creates a new variable. Eg

Select Case and1
Case 1
a1 = "and"
Case 2
a1 = "or"
Case 3
a1 = "and not"
End Select
If [Forms]![search]![Text1] > " " Then
tt1 = "like * " & [Forms]![search]![Text1] & " * "
Else: tt1 = ""
End If
If [Forms]![search]![Text2] > " " Then
tt2 = a1 & " like * " & [Forms]![search]![Text2] & " * "
Else: tt2 = ""
End If
If [Forms]![search]![Text3] > " " Then
Tt3 = a1 & " like * " & [Forms]![search]![Text3] & " * "
Else: Tt3 = ""
End If
If [Forms]![search]![Text4] > " " Then
Tt4 = a1 & " like * " & [Forms]![search]![Text4] & " * "
Else: Tt4 = ""
End If
ttt = tt1 & tt2 & Tt3 & Tt4

I would like to use the value of ttt in sql - how can i do this
please?

Doug

Quote:
Hi,

I am using a form with some text boxes to populate some VBA code that
calls up a query. Using MS Access 2000.

I am using would like my query to read something like:
SELECT * FROM [newvars] where Label like *parm* ;"

... and label is the result of some options, and parm is the result of
a text box input.

Any help appreciated.

Doug

Hello Doug,

Perhaps you can just have the criteria field of your query,
for the field involved, source the text box on your form like:

[Forms]![SourceFormNameHere]![txtParameter]

This will run the query sourcing your text box on the relevant
form. This can be done for each field in your query that needs
to soure your main form.

Regards,

Ray

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.