A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Customizing query fields based on form input



 
 
Thread Tools Display Modes
  #1  
Old July 10th, 2008, 05:47 PM posted to microsoft.public.access.queries
Rus925
external usenet poster
 
Posts: 10
Default Customizing query fields based on form input

I'm using a parameter query that derives the parameters from controls on an
unbound form. Now, I want to put controls on the form that let the user
choose exactly which fields to show and by which field to sort the dataset.
I tried using Excel-style IF statements, but I got an "Undefined function"
error. I tried it again with IIF, and it just didn't work; it gave me one
field that wasn't even in the table (something to the tune of "Expr1010".
Any ideas?
  #2  
Old July 10th, 2008, 06:50 PM posted to microsoft.public.access.queries
Michel Walsh[_2_]
external usenet poster
 
Posts: 56
Default Customizing query fields based on form input

Jet supplies an alias to your computed expression when you don't give one.


You can give an alias, in the query designer grid, with the syntax:

AliasYouWant: expression


such as:


Tax: 0.05 * amount


to compute a tax of 5% over an amount, and calling the result, tax.



Vanderghast, Access MVP


"Rus925" wrote in message
...
I'm using a parameter query that derives the parameters from controls on
an
unbound form. Now, I want to put controls on the form that let the user
choose exactly which fields to show and by which field to sort the
dataset.
I tried using Excel-style IF statements, but I got an "Undefined function"
error. I tried it again with IIF, and it just didn't work; it gave me one
field that wasn't even in the table (something to the tune of "Expr1010".
Any ideas?


  #3  
Old July 10th, 2008, 07:10 PM posted to microsoft.public.access.queries
Rus925
external usenet poster
 
Posts: 10
Default Customizing query fields based on form input

Thanks for your response; that's good to know, but what I'm really looking
for is how to change the visibility of fields in the query, not their names.

"Michel Walsh" wrote:

Jet supplies an alias to your computed expression when you don't give one.


You can give an alias, in the query designer grid, with the syntax:

AliasYouWant: expression


such as:


Tax: 0.05 * amount


to compute a tax of 5% over an amount, and calling the result, tax.



Vanderghast, Access MVP


"Rus925" wrote in message
...
I'm using a parameter query that derives the parameters from controls on
an
unbound form. Now, I want to put controls on the form that let the user
choose exactly which fields to show and by which field to sort the
dataset.
I tried using Excel-style IF statements, but I got an "Undefined function"
error. I tried it again with IIF, and it just didn't work; it gave me one
field that wasn't even in the table (something to the tune of "Expr1010".
Any ideas?


  #4  
Old July 10th, 2008, 08:11 PM posted to microsoft.public.access.queries
Michel Walsh[_2_]
external usenet poster
 
Posts: 56
Default Customizing query fields based on form input

In a form? have a control for each field (controls are on form, fields are
in table/query) and turn them visible/invisible as required. You may have to
change the left property of the control to recuperate the horizontal space
left by a control turned invisible.


Vanderghast, Access MVP


"Rus925" wrote in message
...
Thanks for your response; that's good to know, but what I'm really looking
for is how to change the visibility of fields in the query, not their
names.

"Michel Walsh" wrote:

Jet supplies an alias to your computed expression when you don't give
one.


You can give an alias, in the query designer grid, with the syntax:

AliasYouWant: expression


such as:


Tax: 0.05 * amount


to compute a tax of 5% over an amount, and calling the result, tax.



Vanderghast, Access MVP


"Rus925" wrote in message
...
I'm using a parameter query that derives the parameters from controls
on
an
unbound form. Now, I want to put controls on the form that let the
user
choose exactly which fields to show and by which field to sort the
dataset.
I tried using Excel-style IF statements, but I got an "Undefined
function"
error. I tried it again with IIF, and it just didn't work; it gave me
one
field that wasn't even in the table (something to the tune of
"Expr1010".
Any ideas?



  #5  
Old July 10th, 2008, 09:22 PM posted to microsoft.public.access.queries
Rus925
external usenet poster
 
Posts: 10
Default Customizing query fields based on form input

The form is unbound; it serves only as a nicer UI for entering the parameters
than having an individual dialog box pop up for each one
(http://www.fontstuff.com/access/acctut08.htm). What I want to do is have
some sort of checkbox in the unbound form that would toggle whether or not a
specific field is included in the query. I don't want users to have to go
into design view to customize the query if at all possible. Could such a
thing be written in to the SQL for the query? Could it be done with macro?
I don't understand what you're telling me to do, but I think what you're
saying has to do with hiding controls/fields (correct me if I'm wrong; that's
what I'm confused about) on the form, but I was talking about the fields in
the query's datasheet.

"Michel Walsh" wrote:

In a form? have a control for each field (controls are on form, fields are
in table/query) and turn them visible/invisible as required. You may have to
change the left property of the control to recuperate the horizontal space
left by a control turned invisible.


Vanderghast, Access MVP


"Rus925" wrote in message
...
Thanks for your response; that's good to know, but what I'm really looking
for is how to change the visibility of fields in the query, not their
names.

"Michel Walsh" wrote:

Jet supplies an alias to your computed expression when you don't give
one.


You can give an alias, in the query designer grid, with the syntax:

AliasYouWant: expression


such as:


Tax: 0.05 * amount


to compute a tax of 5% over an amount, and calling the result, tax.



Vanderghast, Access MVP


"Rus925" wrote in message
...
I'm using a parameter query that derives the parameters from controls
on
an
unbound form. Now, I want to put controls on the form that let the
user
choose exactly which fields to show and by which field to sort the
dataset.
I tried using Excel-style IF statements, but I got an "Undefined
function"
error. I tried it again with IIF, and it just didn't work; it gave me
one
field that wasn't even in the table (something to the tune of
"Expr1010".
Any ideas?


  #6  
Old July 10th, 2008, 09:59 PM posted to microsoft.public.access.queries
Michel Walsh
external usenet poster
 
Posts: 2,404
Default Customizing query fields based on form input

You cannot 'select the fields' to be displayed from a query short of writing
the query dynamically, with a string:

Dim str AS string
str= " SELECT "

if check1 then str=str & " field1,"
if check2 then str = str & " field2,"
....

' remove the extra coma ( I assume at least ONE field will be selected)
str=Left(str, len(str)-1)

'complete the statement
str= str & " FROM tableName ... "

'use the string a record source (form/report) or row source (combo box,
list box)



Indeed, I was proposing to hide controls in a form, which should be the way
end users see the data (rather than seeing it through the Access User
Interface, such as through a table or a query).



Vanderghast, Access MVP




"Rus925" wrote in message
...
The form is unbound; it serves only as a nicer UI for entering the
parameters
than having an individual dialog box pop up for each one
(http://www.fontstuff.com/access/acctut08.htm). What I want to do is have
some sort of checkbox in the unbound form that would toggle whether or not
a
specific field is included in the query. I don't want users to have to go
into design view to customize the query if at all possible. Could such a
thing be written in to the SQL for the query? Could it be done with
macro?
I don't understand what you're telling me to do, but I think what you're
saying has to do with hiding controls/fields (correct me if I'm wrong;
that's
what I'm confused about) on the form, but I was talking about the fields
in
the query's datasheet.

"Michel Walsh" wrote:

In a form? have a control for each field (controls are on form, fields
are
in table/query) and turn them visible/invisible as required. You may have
to
change the left property of the control to recuperate the horizontal
space
left by a control turned invisible.


Vanderghast, Access MVP


"Rus925" wrote in message
...
Thanks for your response; that's good to know, but what I'm really
looking
for is how to change the visibility of fields in the query, not their
names.

"Michel Walsh" wrote:

Jet supplies an alias to your computed expression when you don't give
one.


You can give an alias, in the query designer grid, with the syntax:

AliasYouWant: expression


such as:


Tax: 0.05 * amount


to compute a tax of 5% over an amount, and calling the result, tax.



Vanderghast, Access MVP


"Rus925" wrote in message
...
I'm using a parameter query that derives the parameters from
controls
on
an
unbound form. Now, I want to put controls on the form that let the
user
choose exactly which fields to show and by which field to sort the
dataset.
I tried using Excel-style IF statements, but I got an "Undefined
function"
error. I tried it again with IIF, and it just didn't work; it gave
me
one
field that wasn't even in the table (something to the tune of
"Expr1010".
Any ideas?




  #7  
Old July 10th, 2008, 11:04 PM posted to microsoft.public.access.queries
Rus925
external usenet poster
 
Posts: 10
Default Customizing query fields based on form input

Thanks! I've made the edits and everything to work with my DB. Now all I
need to know is where I'm supposed to put this.

"Michel Walsh" wrote:

You cannot 'select the fields' to be displayed from a query short of writing
the query dynamically, with a string:

Dim str AS string
str= " SELECT "

if check1 then str=str & " field1,"
if check2 then str = str & " field2,"
....

' remove the extra coma ( I assume at least ONE field will be selected)
str=Left(str, len(str)-1)

'complete the statement
str= str & " FROM tableName ... "

'use the string a record source (form/report) or row source (combo box,
list box)



Indeed, I was proposing to hide controls in a form, which should be the way
end users see the data (rather than seeing it through the Access User
Interface, such as through a table or a query).



Vanderghast, Access MVP




"Rus925" wrote in message
...
The form is unbound; it serves only as a nicer UI for entering the
parameters
than having an individual dialog box pop up for each one
(http://www.fontstuff.com/access/acctut08.htm). What I want to do is have
some sort of checkbox in the unbound form that would toggle whether or not
a
specific field is included in the query. I don't want users to have to go
into design view to customize the query if at all possible. Could such a
thing be written in to the SQL for the query? Could it be done with
macro?
I don't understand what you're telling me to do, but I think what you're
saying has to do with hiding controls/fields (correct me if I'm wrong;
that's
what I'm confused about) on the form, but I was talking about the fields
in
the query's datasheet.

"Michel Walsh" wrote:

In a form? have a control for each field (controls are on form, fields
are
in table/query) and turn them visible/invisible as required. You may have
to
change the left property of the control to recuperate the horizontal
space
left by a control turned invisible.


Vanderghast, Access MVP


"Rus925" wrote in message
...
Thanks for your response; that's good to know, but what I'm really
looking
for is how to change the visibility of fields in the query, not their
names.

"Michel Walsh" wrote:

Jet supplies an alias to your computed expression when you don't give
one.


You can give an alias, in the query designer grid, with the syntax:

AliasYouWant: expression


such as:


Tax: 0.05 * amount


to compute a tax of 5% over an amount, and calling the result, tax.



Vanderghast, Access MVP


"Rus925" wrote in message
...
I'm using a parameter query that derives the parameters from
controls
on
an
unbound form. Now, I want to put controls on the form that let the
user
choose exactly which fields to show and by which field to sort the
dataset.
I tried using Excel-style IF statements, but I got an "Undefined
function"
error. I tried it again with IIF, and it just didn't work; it gave
me
one
field that wasn't even in the table (something to the tune of
"Expr1010".
Any ideas?





  #8  
Old July 10th, 2008, 11:05 PM posted to microsoft.public.access.queries
Rus925
external usenet poster
 
Posts: 10
Default Customizing query fields based on form input

....and by "this", I mean where I put the code in the DB.

"Michel Walsh" wrote:

You cannot 'select the fields' to be displayed from a query short of writing
the query dynamically, with a string:

Dim str AS string
str= " SELECT "

if check1 then str=str & " field1,"
if check2 then str = str & " field2,"
....

' remove the extra coma ( I assume at least ONE field will be selected)
str=Left(str, len(str)-1)

'complete the statement
str= str & " FROM tableName ... "

'use the string a record source (form/report) or row source (combo box,
list box)



Indeed, I was proposing to hide controls in a form, which should be the way
end users see the data (rather than seeing it through the Access User
Interface, such as through a table or a query).



Vanderghast, Access MVP




"Rus925" wrote in message
...
The form is unbound; it serves only as a nicer UI for entering the
parameters
than having an individual dialog box pop up for each one
(http://www.fontstuff.com/access/acctut08.htm). What I want to do is have
some sort of checkbox in the unbound form that would toggle whether or not
a
specific field is included in the query. I don't want users to have to go
into design view to customize the query if at all possible. Could such a
thing be written in to the SQL for the query? Could it be done with
macro?
I don't understand what you're telling me to do, but I think what you're
saying has to do with hiding controls/fields (correct me if I'm wrong;
that's
what I'm confused about) on the form, but I was talking about the fields
in
the query's datasheet.

"Michel Walsh" wrote:

In a form? have a control for each field (controls are on form, fields
are
in table/query) and turn them visible/invisible as required. You may have
to
change the left property of the control to recuperate the horizontal
space
left by a control turned invisible.


Vanderghast, Access MVP


"Rus925" wrote in message
...
Thanks for your response; that's good to know, but what I'm really
looking
for is how to change the visibility of fields in the query, not their
names.

"Michel Walsh" wrote:

Jet supplies an alias to your computed expression when you don't give
one.


You can give an alias, in the query designer grid, with the syntax:

AliasYouWant: expression


such as:


Tax: 0.05 * amount


to compute a tax of 5% over an amount, and calling the result, tax.



Vanderghast, Access MVP


"Rus925" wrote in message
...
I'm using a parameter query that derives the parameters from
controls
on
an
unbound form. Now, I want to put controls on the form that let the
user
choose exactly which fields to show and by which field to sort the
dataset.
I tried using Excel-style IF statements, but I got an "Undefined
function"
error. I tried it again with IIF, and it just didn't work; it gave
me
one
field that wasn't even in the table (something to the tune of
"Expr1010".
Any ideas?





 




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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:42 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.