Starting query from a form (criterium being based on a text field in the form) 
Author Message
 Starting query from a form (criterium being based on a text field in the form)

Hello,

In a form I have some text field. This text field may contain 5
different values (1,2,3,4 or 5)

In the same form I have also a push button. When this button is being
pushed a query will be opened.

But it should open the query with the exact criterium, based on the
value in the text field (1,2,3,4 or 5).

So the criterium in the query has to be 1,2,3,4 or 5 automatically.

How do I do this?

Email please...

  tor-4216.vcf
< 1K Download


Tue, 16 Jan 2001 03:00:00 GMT  
 Starting query from a form (criterium being based on a text field in the form)
There are basically two ways you can do this:  By building the query on the
fly based on the fields entered, or by putting a matching criteria field on
a prebuilt query grid and referencing your form.   If you don't want to
write code, simply put something like

        Forms!MyForm![TextField]

on the criteria line of the query grid under the field you're comparing.
Use your form button to issue a DoCmd.OpenQuery and you should see the
correct information in the query.

--
C{*filter*}te Foust



Quote:
> In a form I have some text field. This text field may contain 5
> different values (1,2,3,4 or 5)
> So the criterium in the query has to be 1,2,3,4 or 5 automatically.

> How do I do this?



Tue, 16 Jan 2001 03:00:00 GMT  
 Starting query from a form (criterium being based on a text field in the form)
Sorry no emails.  You post 'em here, we answer 'em here.

You need to construct the WHERE clause yourself.  If the string is separated
by commas or another character, take a peek at the Strings section at my
website for the article "Parsing character separated string into individual
components".  Use it to break the value into a series of OR and pass it to
BuildCriteria (in Access 97) to return the entire WHERE clause.

?Application.BuildCriteria("someField",dbInteger,"1 or 2 or 3 or 5 or 4")
someField=1 Or someField=2 Or someField=3 Or someField=5 Or someField=4

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

:Hello,
:
:In a form I have some text field. This text field may contain 5
:different values (1,2,3,4 or 5)
:
:In the same form I have also a push button. When this button is being
:pushed a query will be opened.
:
:But it should open the query with the exact criterium, based on the
:value in the text field (1,2,3,4 or 5).
:
:So the criterium in the query has to be 1,2,3,4 or 5 automatically.
:
:How do I do this?
:
:Email please...
:



Wed, 17 Jan 2001 03:00:00 GMT  
 Starting query from a form (criterium being based on a text field in the form)

Thank You C{*filter*}te,

But this way, when I push the button I get a  dialog box that asks for a
parameter.

How can I avoid this?

Quote:

> There are basically two ways you can do this:  By building the query on the
> fly based on the fields entered, or by putting a matching criteria field on
> a prebuilt query grid and referencing your form.   If you don't want to
> write code, simply put something like

>         Forms!MyForm![TextField]

> on the criteria line of the query grid under the field you're comparing.
> Use your form button to issue a DoCmd.OpenQuery and you should see the
> correct information in the query.

> --
> C{*filter*}te Foust



> > In a form I have some text field. This text field may contain 5
> > different values (1,2,3,4 or 5)
> > So the criterium in the query has to be 1,2,3,4 or 5 automatically.

> > How do I do this?

  tor-4216.vcf
< 1K Download


Fri, 19 Jan 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. queries form a text based database

2. Help with linking forms - query based on master form

3. form VB form to web based form

4. Protected Forms and Text Form Fields

5. Loss of form field text after unprotecting and protecting a form

6. Solution for form based queries to Excel Automation

7. Using forms to select a report from multiple base queries

8. Creating an Update to New Record Command Button on Form Based on Multitable Query

9. Query based form, Help please.

10. How to Query on Data Enviroment based data form

11. on entry form text field macro - year field

12. Problem when unprotecting a document with form field text fields

 

 
Powered by phpBB® Forum Software