dbTalk Databases Forums  

Help with QBE

comp.databases.ms-access comp.databases.ms-access


Discuss Help with QBE in the comp.databases.ms-access forum.



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

Default Help with QBE - 07-16-2010 , 02:01 AM






I am using Access 2003 and want to have a query return results based
on the value a text box in a hidden form. Depending on the value in
the text box the result should be to show a filtered selection or show
all records.

If Sales is the value in the text box, then Sales staff could view
only records for the Sales department and so on with Service, Research
departments. However if the value is Director then I want it to show
all records.

I am using this but it doesn't work when it comes to showing all
records

IIf([Forms]![frmHidden]![txtAgency]="Director","*",[Forms]!
[frmHidden]![txtAgency])

Most grateful for your assistance.

VT

Reply With Quote
  #2  
Old   
Douglas J. Steele
 
Posts: n/a

Default Re: Help with QBE - 07-16-2010 , 06:49 AM






My advice would be to use

[Forms]![frmHidden]![txtAgency] Or
[Forms]![frmHidden]![txtAgency]="Director"

although you could also just put Like in front of what you've currently got:

Like
IIf([Forms]![frmHidden]![txtAgency]="Director","*",[Forms]![frmHidden]![txtAgency])

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/djsteele
Co-author: "Access 2010 Solutions", published by Wiley
(no e-mails, please!)



"Vet Tech" <senditontome (AT) gmail (DOT) com> wrote

Quote:
I am using Access 2003 and want to have a query return results based
on the value a text box in a hidden form. Depending on the value in
the text box the result should be to show a filtered selection or show
all records.

If Sales is the value in the text box, then Sales staff could view
only records for the Sales department and so on with Service, Research
departments. However if the value is Director then I want it to show
all records.

I am using this but it doesn't work when it comes to showing all
records

IIf([Forms]![frmHidden]![txtAgency]="Director","*",[Forms]!
[frmHidden]![txtAgency])

Most grateful for your assistance.

VT

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

Default Re: Help with QBE - 07-16-2010 , 09:44 AM



On 16/07/2010 12:49:40, "Douglas J. Steele" wrote:
Quote:
My advice would be to use

[Forms]![frmHidden]![txtAgency] Or
[Forms]![frmHidden]![txtAgency]="Director"

although you could also just put Like in front of what you've currently
got:

Like
IIf([Forms]![frmHidden]![txtAgency]="Director","*",[Forms]![frmHidden]![txtAgency])

Try putting another field on your form TxtAgencyRelay with the ControlSource
'=IIf([TxtAgency]) = "Director", "*"[TxtAgency])'

and your query criteria
Like [Forms]![frmHidden]![txtAgencyRelay]

Reply With Quote
  #4  
Old   
Douglas J. Steele
 
Posts: n/a

Default Re: Help with QBE - 07-18-2010 , 09:05 PM



"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 16/07/2010 12:49:40, "Douglas J. Steele" wrote:
My advice would be to use

[Forms]![frmHidden]![txtAgency] Or
[Forms]![frmHidden]![txtAgency]="Director"

although you could also just put Like in front of what you've currently
got:

Like
IIf([Forms]![frmHidden]![txtAgency]="Director","*",[Forms]![frmHidden]![txtAgency])


Try putting another field on your form TxtAgencyRelay with the
ControlSource
'=IIf([TxtAgency]) = "Director", "*"[TxtAgency])'

and your query criteria
Like [Forms]![frmHidden]![txtAgencyRelay]
That won't work Phil, if only because the IIf statement is invalid syntax
(looks as though you left out a comma). Even if you correct the syntax,
though, I think you'll find it won't do what's asked for.

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/djsteele
Co-author: "Access 2010 Solutions", published by Wiley
(no e-mails, please!)

Reply With Quote
  #5  
Old   
Phil
 
Posts: n/a

Default Re: Help with QBE - 07-19-2010 , 02:36 AM



On 19/07/2010 03:05:19, "Douglas J. Steele" wrote:
Quote:
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in message
news:GOqdnTh2BuDN7d3RnZ2dnUVZ8nydnZ2d (AT) brightview (DOT) co.uk...
On 16/07/2010 12:49:40, "Douglas J. Steele" wrote:
My advice would be to use

[Forms]![frmHidden]![txtAgency] Or
[Forms]![frmHidden]![txtAgency]="Director"

although you could also just put Like in front of what you've currently
got:

Like
IIf([Forms]![frmHidden]![txtAgency]="Director","*",[Forms]![frmHidden]![txtAgency])


Try putting another field on your form TxtAgencyRelay with the
ControlSource
'=IIf([TxtAgency]) = "Director", "*"[TxtAgency])'

and your query criteria
Like [Forms]![frmHidden]![txtAgencyRelay]

That won't work Phil, if only because the IIf statement is invalid syntax
(looks as though you left out a comma). Even if you correct the syntax,
though, I think you'll find it won't do what's asked for.

Hi Douglas
Typo error Should be '=IIf([TxtAgency]) = "Director", "*",[TxtAgency])'

I use a similar routine to select surnames based on an initial letter
selected from a grid where I load that letter into into a field on the form,
or if I choose the "All" option it loads an * into the field. Works fine

Phil

Reply With Quote
  #6  
Old   
Douglas J. Steele
 
Posts: n/a

Default Re: Help with QBE - 07-19-2010 , 06:01 AM



"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 19/07/2010 03:05:19, "Douglas J. Steele" wrote:
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in message
news:GOqdnTh2BuDN7d3RnZ2dnUVZ8nydnZ2d (AT) brightview (DOT) co.uk...
On 16/07/2010 12:49:40, "Douglas J. Steele" wrote:
My advice would be to use

[Forms]![frmHidden]![txtAgency] Or
[Forms]![frmHidden]![txtAgency]="Director"

although you could also just put Like in front of what you've currently
got:

Like
IIf([Forms]![frmHidden]![txtAgency]="Director","*",[Forms]![frmHidden]![txtAgency])


Try putting another field on your form TxtAgencyRelay with the
ControlSource
'=IIf([TxtAgency]) = "Director", "*"[TxtAgency])'

and your query criteria
Like [Forms]![frmHidden]![txtAgencyRelay]

That won't work Phil, if only because the IIf statement is invalid syntax
(looks as though you left out a comma). Even if you correct the syntax,
though, I think you'll find it won't do what's asked for.


Hi Douglas
Typo error Should be '=IIf([TxtAgency]) = "Director", "*",[TxtAgency])'

I use a similar routine to select surnames based on an initial letter
selected from a grid where I load that letter into into a field on the
form,
or if I choose the "All" option it loads an * into the field. Works fine

My apologies. I see now what you're trying to do.

I don't see any advantage, though, of adding an additional control to the
form vs. having the query do the work.

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
Co-author: Access 2010 Solutions, published by Wiley
(no e-mails, please!)

Reply With Quote
  #7  
Old   
Phil
 
Posts: n/a

Default Re: Help with QBE - 07-19-2010 , 07:07 AM



On 19/07/2010 12:01:09, "Douglas J. Steele" wrote:
Quote:
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in message
news:EbidndVwHvgSndnRnZ2dnUVZ8tydnZ2d (AT) brightview (DOT) co.uk...
On 19/07/2010 03:05:19, "Douglas J. Steele" wrote:
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in message
news:GOqdnTh2BuDN7d3RnZ2dnUVZ8nydnZ2d (AT) brightview (DOT) co.uk...
On 16/07/2010 12:49:40, "Douglas J. Steele" wrote:
My advice would be to use

[Forms]![frmHidden]![txtAgency] Or
[Forms]![frmHidden]![txtAgency]="Director"

although you could also just put Like in front of what you've currently
got:

Like
IIf([Forms]![frmHidden]![txtAgency]="Director","*",[Forms]![frmHidden]![txtAgency])


Try putting another field on your form TxtAgencyRelay with the
ControlSource
'=IIf([TxtAgency]) = "Director", "*"[TxtAgency])'

and your query criteria
Like [Forms]![frmHidden]![txtAgencyRelay]

That won't work Phil, if only because the IIf statement is invalid syntax
(looks as though you left out a comma). Even if you correct the syntax,
though, I think you'll find it won't do what's asked for.


Hi Douglas
Typo error Should be '=IIf([TxtAgency]) = "Director", "*",[TxtAgency])'

I use a similar routine to select surnames based on an initial letter
selected from a grid where I load that letter into into a field on the
form,
or if I choose the "All" option it loads an * into the field. Works fine


My apologies. I see now what you're trying to do.

I don't see any advantage, though, of adding an additional control to the
form vs. having the query do the work.

Apology accepted.

You're probably right about it being a complex way of doing things, but that
method works, and the OP seemed to be having dificulties with his query

Phil

Reply With Quote
  #8  
Old   
Vet Tech
 
Posts: n/a

Default Re: Help with QBE - 07-19-2010 , 03:33 PM



It appears it may have been a Null problem.

I used the Nz thingie and it has worked out OK so far.

This is what I put in:-

Like Nz([forms]![frmHidden]![txtAgency],"") & "*"

Many thanks anyway for your suggestions.

VT

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.