dbTalk Databases Forums  

Can I modify a Query expression at runtime?

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


Discuss Can I modify a Query expression at runtime? in the comp.database.ms-access forum.



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

Default Can I modify a Query expression at runtime? - 05-06-2004 , 01:35 PM






Hi,

I have a simple form that contains a combobox, which has supplier
names in it.
A report is run based on a simple query. The report displays supplier
details for a particular supplier that had been selected from the
combobox.

Basically I want the query to be able to handle the following
scenario:-

Have a look at the combobox value and display records for that
particular supplier. (this is currently achieved)

However if no items have been selected from the combobox then display
details for all suppliers. How can I translate this to a queries
expression builder?

Any ideas would be most welcome.

Thanks

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

Default Re: Can I modify a Query expression at runtime? - 05-07-2004 , 07:35 AM






kamal_akhtar (AT) hotmail (DOT) com (Kamal Akhtar) wrote in message news:<64ad11db.0405061035.48d5c7c0 (AT) posting (DOT) google.com>...
Quote:
Hi,

I have a simple form that contains a combobox, which has supplier
names in it.
A report is run based on a simple query. The report displays supplier
details for a particular supplier that had been selected from the
combobox.

Basically I want the query to be able to handle the following
scenario:-

Have a look at the combobox value and display records for that
particular supplier. (this is currently achieved)

However if no items have been selected from the combobox then display
details for all suppliers. How can I translate this to a queries
expression builder?

Any ideas would be most welcome.

Thanks
Hello,

First of all, it wasn't stated how your getting the combox value
and using it in your query. As such I'll assume that the criteria
expression in your query for the field being sourced looks something
like this:

[Forms]![frmFormNameHere]![cmbComboNameHere]

This forces the query to look to your form, with the combobox,
for the information required.

Now, if you want to display all data if there is no data in the
combobox, duplicate the expression above by adding an "or" after
it and copying the expression and pasting it after the or with
an "IsNull" at the end.

Example:

[Forms]![frmFormNameHere]![cmbComboNameHere] or
[Forms]![frmFormNameHere]![cmbComboNameHere] is null

What happens is, the query looks for it's criteria in the combobox
and if it is null, then will display all records.

Regards,

Ray


Reply With Quote
  #3  
Old   
Kamal Akhtar
 
Posts: n/a

Default Re: Can I modify a Query expression at runtime? - 05-07-2004 , 01:30 PM



Ray,

Thanks for your reply.

It works a treat.

raycait (AT) excite (DOT) com (Ray) wrote in message news:<20ba9f4a.0405070435.4906cc68 (AT) posting (DOT) google.com>...
Quote:
kamal_akhtar (AT) hotmail (DOT) com (Kamal Akhtar) wrote in message news:<64ad11db.0405061035.48d5c7c0 (AT) posting (DOT) google.com>...
Hi,

I have a simple form that contains a combobox, which has supplier
names in it.
A report is run based on a simple query. The report displays supplier
details for a particular supplier that had been selected from the
combobox.

Basically I want the query to be able to handle the following
scenario:-

Have a look at the combobox value and display records for that
particular supplier. (this is currently achieved)

However if no items have been selected from the combobox then display
details for all suppliers. How can I translate this to a queries
expression builder?

Any ideas would be most welcome.

Thanks

Hello,

First of all, it wasn't stated how your getting the combox value
and using it in your query. As such I'll assume that the criteria
expression in your query for the field being sourced looks something
like this:

[Forms]![frmFormNameHere]![cmbComboNameHere]

This forces the query to look to your form, with the combobox,
for the information required.

Now, if you want to display all data if there is no data in the
combobox, duplicate the expression above by adding an "or" after
it and copying the expression and pasting it after the or with
an "IsNull" at the end.

Example:

[Forms]![frmFormNameHere]![cmbComboNameHere] or
[Forms]![frmFormNameHere]![cmbComboNameHere] is null

What happens is, the query looks for it's criteria in the combobox
and if it is null, then will display all records.

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.