Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2007

Tip: Looking for answers? Try searching our database.

Command Button - using Queries

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
learning_codes@hotmail.com - 31 Mar 2007 12:24 GMT
Hi,

I have about 40 Queries by Year.   I don't want to write it down one
by one to make a command button.

   DoCmd.OpenQuery "2007", acViewNormal, acEdit
   DoCmd.OpenQuery "20071", acViewNormal, acEdit
   DoCmd.OpenQuery "20072", acViewNormal, acEdit

I'm tired if I make the change then I have to go back the command
button to adjust the name of the queries.

Is there a way for create a code for "Like 2007*" or Like 2006* or
Like 2005* or Like 2004*, etc. in one command button.

   DoCmd.OpenQuery "2007", acViewNormal, acEdit
   DoCmd.OpenQuery "2006", acViewNormal, acEdit
   DoCmd.OpenQuery "2005", acViewNormal, acEdit
   DoCmd.OpenQuery "2004", acViewNormal, acEdit

Your help would be much appreciated.

Thanks
Douglas J. Steele - 31 Mar 2007 12:45 GMT
No, there's no way to have the OpenQuery command do that, but you could easy
run a loop in VBA to go through all the queries and only run those that
match a certain criteria:

Dim dbCurr As DAO.Database
Dim qdfCurr As DAO.QueryDef

 Set dbCurr = CurrentDb()
 For Each qdfCurr In dbCurr.QueryDefs
   If Left$(qdfCurr.Name, 4) = "2007" Then
     DoCmd.OpenQuery qdfCurr.Name, acViewNormal, acEdit
   End If
 Next qdfCurr

For the life of me, though, I don't understand why you'd want to do that:
queries aren't intended to be interacted with.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Hi,
>
[quoted text clipped - 19 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.