Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 20th, 2008, 05:34 AM
bal1 bal1 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 9 bal1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 4 sec
Reputation Power: 0
Forms - Field as criteria

Hi,

I am trying to build a form with a list box that runs a query. In the query I have several tables that return details in the query for one of the tables I want the field to change depedning on what the user selects in the list box on the form.

e.g
I have a table for countries and fields are different country names with a list of names in each country.

I can make a static query that returns details for the names specific to that country but by selecting the country name as the field in the query design. However I want the field selection to be based upon what the user selects on the form list box.

I'm new to access and dont know any VB.

Thanks in advance for your kind help.

Regards
Bal

Reply With Quote
  #2  
Old May 20th, 2008, 06:12 AM
AOG123's Avatar
AOG123 AOG123 is offline
Registered Hero
ASP Free Novice (500 - 999 posts)
 
Join Date: Oct 2006
Posts: 974 AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 28 m 34 sec
Reputation Power: 1325
In your query you need to refer to the value selected in the list box,.

for example,..
Code:
Like "*" & [Forms]![FormName]![ListBoxName] & "*"


Take a look at this example which is similar to what you are after,.. but form based.

<<<<List Box Filter>>>>

Reply With Quote
  #3  
Old May 20th, 2008, 06:22 AM
bal1 bal1 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 9 bal1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 4 sec
Reputation Power: 0
Thanks very much for your help.

Do I add this line in the Criteria section or field name section in the Query Design view?

I couldn't open the example because my internet is restricted at work - will download at home and work through it. Thanks for this.

Regards
Bal

Reply With Quote
  #4  
Old May 20th, 2008, 06:27 AM
AOG123's Avatar
AOG123 AOG123 is offline
Registered Hero
ASP Free Novice (500 - 999 posts)
 
Join Date: Oct 2006
Posts: 974 AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 28 m 34 sec
Reputation Power: 1325
Quote:
Originally Posted by bal1
Thanks very much for your help.

Do I add this line in the Criteria section or field name section in the Query Design view?

I couldn't open the example because my internet is restricted at work - will download at home and work through it. Thanks for this.

Regards
Bal


In the criterial line of the field you are filtering,...

in regards to your iif statement in the other post,.. that goes in the field line. P.s,.. it should look something like
Code:
Iif([Field] = "whatever", [thisValuefield],[orthisvalueField])

Last edited by AOG123 : May 20th, 2008 at 06:31 AM.

Reply With Quote
  #5  
Old May 20th, 2008, 06:55 AM
bal1 bal1 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 9 bal1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 4 sec
Reputation Power: 0
If I predefine a field in the query and put this code in the criteria line will the field then change according to what is selected in the form or does this only qwork with values?


I tried the If statement in the field name section and got an error saying:"The expression you entered contains invalid syntax - You may have entered an operand without an operator"

I typed:

Iif(tblGeneralItems.[Enter SOE Wrap ID] = "*_as*", tblMy Prod.[Enter SOE ID], tblGeneral Items.[Enter SOE Wrap ID])

Thanks alot for your help, my Access skills are very poor.

Kind Regards
Bal

Reply With Quote
  #6  
Old May 20th, 2008, 07:08 AM
AOG123's Avatar
AOG123 AOG123 is offline
Registered Hero
ASP Free Novice (500 - 999 posts)
 
Join Date: Oct 2006
Posts: 974 AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level)AOG123 User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 28 m 34 sec
Reputation Power: 1325
my fault,.. iif statement question answered in correct thread,.. we'll keep this thread for the list box

Reply With Quote
  #7  
Old May 20th, 2008, 09:06 AM
bal1 bal1 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 9 bal1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 4 sec
Reputation Power: 0
cheers,

With Regards to if statement I keep getting the enter value dialog box. I did remove the spaces in teh source table but still got the message so not sure why its coming up. Problem is they are linked tables to excel spreadsheets which are reports from another db so the spaces will come back even if I get it to work.

With the list box I put the code you provided in the criteria part:

Like "*" & [Forms]![frmReport]![Select Region] & "*"

I choose one of the fields (country/region name) Wave 5 in this case. Then save and go to the form "frmReport". I click the list box (row Source is a table called Regions & row type is a field list) this drops the list of countries. I select onw and nothing happens. I need it to run the query with the specifid parameters but change the field for the first column to which ever country is selected.

I think I need to take the time out and go through an Access text book.

regards,
Bal

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Forms - Field as criteria


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT