Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 7th, 2005, 08:47 AM
summer brew summer brew is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 12 summer brew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 8 sec
Reputation Power: 0
Executing Functions From a Multiselect Listbox

I have a form with a multiselect listbox setup with the names of queries that I already have setup within Access. I would like to be able to execute those queries from this form, but have the ability to execute at least two or more at a time.

I have scoured the internet for the last two days and have come up with nothing, nor have I been able to find anything similar to what I'm looking to achieve. I have found a number of ways to create queries from a multiselect list box in a form, but no way to execute queries.

I am just starting out in VBA, and I know this is going to recquire a substantial amount of code, so I'm reaching out for HELP!

Big thanks in advance for helping me out...

Paul

Reply With Quote
  #2  
Old July 7th, 2005, 09:55 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
Place a command button on your form and in the On Click event paste this code:

Dim strQueryName As String
Dim varItem As Variant
For Each varItem In Me!ListBoxName.ItemsSelected
strQueryName = Me!ListBoxName.ItemData(varItem)
DoCmd.OpenQuery strQueryName
Next varItem

This will open the queries you selected in your list box. Just change the DoCmd.OpenQuery to whatever you wanted to do with the queries that were selected in the list box. Use the correct name of your list box in the above example.

lwells

Reply With Quote
  #3  
Old July 12th, 2005, 03:03 PM
summer brew summer brew is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 12 summer brew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 8 sec
Reputation Power: 0
Worked wonderfully...

Thank you, thank you, thank you....

I have a question though:

There is a query amongst the list that I plan on running that has a specific criteria in one of the fields, and I would like to know how to run them in succession and when that query comes to run I am asked to enter in the specific criteria.

Thank you!

Paul

Reply With Quote
  #4  
Old July 12th, 2005, 03:26 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
In the query that will have a specific criteria for you to enter manually, in the criteria row below the field to sort on, type in [Enter Specific Criteria] with the brackets.

Then when that query tries to run, it will open the parameter box for you to enter the specific criteria.

Was this what you were asking?

lwells

Reply With Quote
  #5  
Old July 13th, 2005, 01:44 PM
summer brew summer brew is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 12 summer brew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 8 sec
Reputation Power: 0
That was along the lines of what I was asking...

However, I need it to automatically do it without any input. The criteria is never going to change; it will always be any record that is less than the current month, which is displayed as YearMonth (200507).

Is there a way to put that criteria into the VB code that runs the query, and automatically drops in the year and month, or can i use code within the query itself to automate this process, or I am simply stuck with having the user input the particular criteria???

THanks!

-Paul

Reply With Quote
  #6  
Old July 13th, 2005, 02:28 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
Yes it is possible. What is the datatype for the field, is it a text or a date? If it is a concantinated string calculation from a date field then it will be text.

Reply With Quote
  #7  
Old July 13th, 2005, 02:44 PM
summer brew summer brew is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 12 summer brew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 8 sec
Reputation Power: 0
The field in the table that it originates from is Text.

Reply With Quote
  #8  
Old July 13th, 2005, 05:01 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
For your criteria, this should work <Format(Date(),"yyyymm")
This will return records older than the current month

lwells

Reply With Quote
  #9  
Old July 14th, 2005, 09:04 AM
summer brew summer brew is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 12 summer brew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 8 sec
Reputation Power: 0
I can just drop that into the criteria field in my query?

Reply With Quote
  #10  
Old July 14th, 2005, 09:38 AM
betsypon betsypon is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 11 betsypon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 12 m 37 sec
Reputation Power: 0
Hi lwells,

Reply With Quote
  #11  
Old July 14th, 2005, 04:29 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
Yes that is correct

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Executing Functions From a Multiselect Listbox


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway