Select Case help needed

I'm using a Select Case statement to check the value of 24 checkboxes on a 
form. If true for each case, run the related query.  It seems to be running 
the first query it comes to and not continuing to check the rest.  Below is 
sample code for the first 4 checkboxes.  Can anyone help?

Select Case True
    Case Me.chkQCT01.value = True
    DoCmd.OpenQuery "AccessMWapp", acNormal, acEdit
    Case Me.chkQCT02.value = True
    DoCmd.OpenQuery "AccessSEapp", acNormal, acEdit
    Case Me.chkQCT03.value = True
    DoCmd.OpenQuery "AccessSWapp", acNormal, acEdit
    Case Me.chkQCT04.value = True
    DoCmd.OpenQuery "AccessWapp", acNormal, acEdit
End Select

Thanks,
Jim
0
Utf
2/15/2010 5:39:01 PM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
754 Views

Similar Articles

[PageSpeed] 25

Jim -

That is what a SELECT CASE statement does.  It finds the first match and 
ignores the rest.

If you want to run a query for every TRUE, then just use IF statements, like 
this:

    If Me.chkQCT01.value Then 
       DoCmd.OpenQuery "AccessMWapp", acNormal, acEdit
    End If
    If Me.chkQCT02.value Then 
       DoCmd.OpenQuery "AccessSEapp", acNormal, acEdit
    End If
    If Me.chkQCT03.value Then 
       DoCmd.OpenQuery "AccessSWapp", acNormal, acEdit
    End If
    If Me.chkQCT04.value Then 
       DoCmd.OpenQuery "AccessWapp", acNormal, acEdit
    End If

-- 
Daryl S


"Jim" wrote:

> I'm using a Select Case statement to check the value of 24 checkboxes on a 
> form. If true for each case, run the related query.  It seems to be running 
> the first query it comes to and not continuing to check the rest.  Below is 
> sample code for the first 4 checkboxes.  Can anyone help?
> 
> Select Case True
>     Case Me.chkQCT01.value = True
>     DoCmd.OpenQuery "AccessMWapp", acNormal, acEdit
>     Case Me.chkQCT02.value = True
>     DoCmd.OpenQuery "AccessSEapp", acNormal, acEdit
>     Case Me.chkQCT03.value = True
>     DoCmd.OpenQuery "AccessSWapp", acNormal, acEdit
>     Case Me.chkQCT04.value = True
>     DoCmd.OpenQuery "AccessWapp", acNormal, acEdit
> End Select
> 
> Thanks,
> Jim
0
Utf
2/15/2010 5:45:01 PM
"Jim" <Jim@discussions.microsoft.com> wrote in message 
news:FA934E54-EBCE-43D6-BD4F-19EEBEF90F97@microsoft.com...
> I'm using a Select Case statement to check the value of 24 checkboxes on a
> form. If true for each case, run the related query.  It seems to be 
> running
> the first query it comes to and not continuing to check the rest.  Below 
> is
> sample code for the first 4 checkboxes.  Can anyone help?
>
> Select Case True
>    Case Me.chkQCT01.value = True
>    DoCmd.OpenQuery "AccessMWapp", acNormal, acEdit
>    Case Me.chkQCT02.value = True
>    DoCmd.OpenQuery "AccessSEapp", acNormal, acEdit
>    Case Me.chkQCT03.value = True
>    DoCmd.OpenQuery "AccessSWapp", acNormal, acEdit
>    Case Me.chkQCT04.value = True
>    DoCmd.OpenQuery "AccessWapp", acNormal, acEdit
> End Select


The function of the Select Case statement is to resolve to at most one --  
and only one -- case.  So if you have a series of cases, only the first one 
whose condition evaluates as True will be executed.

If more than one of your check boxes could be True, then don't use Select 
Case.  Use a series of "If ... End If" blocks instead:

    If Me.chkQCT01 = True Then
        DoCmd.OpenQuery "AccessMWapp", acNormal, acEdit
    End If
    If Me.chkQCT02 = True Then
        DoCmd.OpenQuery "AccessSEapp", acNormal, acEdit
    End If
    If Me.chkQCT03 = True Then
        DoCmd.OpenQuery "AccessSWapp", acNormal, acEdit
    End If
    If Me.chkQCT04 = True Then
        DoCmd.OpenQuery "AccessWapp", acNormal, acEdit
    End If


-- 
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

0
Dirk
2/15/2010 5:50:48 PM
Reply:

Similar Artilces:

Automatically selecting active chart
I have the following marco below. I would like to change it so that I do not have to select an active chart before running it. Instead, I would like it to always run for the chart in sheet titled "Benchmark Comp Chart". Please note, there is never more than one chart in that sheet. Currently, since I have to select an active chart, I have to run this while my active sheet is "Benchmark Comp Chart". Going forward, I wish to run it while my active sheet is titled "Misc.". Sub GetChartValues() Dim NumberOfRows As Integer Dim X As Object ...

Help on how to use Offset in Excel
Can anyone explain how OFFSET works in Excel? I'm trying to find out how to use this in order to create a sports league table for my school coursework. Can anyone help please? Thanks in advance. -- petros89 ------------------------------------------------------------------------ petros89's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=24645 View this thread: http://www.excelforum.com/showthread.php?threadid=474047 Excel's Help is generally quite informative about what functions will do. What are you not finding clear about Help for OFFSET ? Jerry ...

Help with autofilter and filtering a specific column
in a macro that filters a specific column i have the following code... ActiveSheet.Range("A7:CQ199").AutoFilter Field:=31, Criteria1:="=3", _ Operator:=xlOr, Criteria2:="=4" however, i have since given everything named ranges to make the table more dynamic (so i dont have to modify my code everytime i add a column or another row of data). so what i want to filter is column AE (hence field 31). i named it ("AE7:AE199") "list"... but when i modify the existing code to... ActiveSheet.Range("list").AutoFilter Fiel...

query help
I am reviewing some old code and the below query is the one I like not to use subquer. Is there a different way to write this query? update tblProduct set ProductCatory_name = 'Hard' where ProductCat_id =400 or ProductCat_id in ( select pdt.productCat_ID from tblProduct as Pdt where pdt.ProductSource_ID = 400 and pdt.Manager_ID >0) OD -- Message posted via SQLMonster.com http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-programming/201001/1 What's wrong with using a subquery? -- Tom ---------------------------------------------------- ...

Help with a DLookUp
Haven't got this just right cant be that far away, need some HELP! Thanks for any help....Bob ="Last Payment" +DLookUp("BillDate"+"PaidAmount","qryAccountStatus","OwnerID=" & [tbOwnerID]) If you're trying to return both the BillDate and PaidAmount in a single lookup, use ="Last Payment" +DLookUp("[BillDate] & ' ' & [PaidAmount]","qryAccountStatus","OwnerID=" &[tbOwnerID]) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) &...

Single v. Double Help
Why is 'ans1' true if double and false for single? Module Module1 Sub Main() Dim x As Double / Single Dim y As Double / Single Dim ans1 As Boolean Dim ans2 As Boolean x = 0.3000000000000001 y = Math.Round(x, 2) ans1 = y = 0.3 ans2 = Math.Round(y, 2) = 0.3 End Sub End Module Thanks Todd -- Am 08.04.2010 00:55, schrieb Todd Heiks: > Why is 'ans1' true if double and false for single? >[...] > Dim x As Double / Single > Dim y As Double / Sing...

Can not get Excel macros to format/save charts--help??? :(((((
Help??:((( I've spent the last 5 days searching on this forum for problems similar to what I have but no luck! I am trying to use Excel macro to create a simple bar chart and to format the chart type/etc...but the macro keeps erroring when I try to run it. The debug points to " ' Set ActiveChart = ActiveSheet.ChartObjects(Chart1)" run time error 1004. No matter what I name the chart, it errors. I'm advanced at Excel but not editing macros with VB. I'm at my wits end and hope that someone can help me :(( Hi, You do not set the Activechart ob...

Textbox value automatically selected, How?
This has to be a simple one. When opening a userform I would like the value stored in the firs textbox to be selected. Therefore I can just start typing over th current value. Currently I have to click and drag the mouse over th old value to select it -- Message posted from http://www.ExcelForum.com Kevlar Try Private Sub UserForm_Activate() Me.TextBox1.SelStart = 0 Me.TextBox1.SelLength = Len(Me.TextBox1) End Su -- Message posted from http://www.ExcelForum.com That works well. Thanks Now, how do I get the list of choices in a listbox to default to th top ite -- Message posted from...

MSCRM API failing with User defined fields.Help !
Iam programming in ASP.NET for my company's MSCRM. I use MSAPI to retrieve and update field values in MSCRM. Iam able to do it with ease by programming in VB.NET with the MSCRM object library. Eg. strUpdateXml = "<account><name>Steve Langer</name><owninguser>{19838938-705A-4AB9-BC2E-2EDD88035EE5}</owninguser> </account>" CRMAccount.Update(UserAuth, RECID, strUpdateXml) It works fine for the normal MSCRM fields LATER, I created USERDEFINED fields in MSCRM. ( with the Deployment Manager and published). The new field created can been seen in...

Immediate Need for a .Net Developer with Microsoft Dynamics CRM
Immediate Need for a .Net Developer with Microsoft Dynamics CRM 5-6 Years of experience as a .Net Developer needed -Strong knowledge with web technologies including ASP/ASP.NET, C#, VBScript, JavaScript, COM. -Strong knowledge in web application middleware and system infrastructure. -Solid understanding of data modeling and relational database systems including SQL Server and Sybase. -Excellent interpersonal and communication skills are essential, as well as the ability to work collaboratively and cooperatively in a team environment. -Must possess high degree of initiative, thoroughness, or...

Help, experts needed! Auto notification
I have an excel spreadsheet with five columns. On column D I have a drop down list with four choices ("n/a" , "Grp1" , "Grp2" , "Grp3"). When a row is filled in, one of the four choices in column D has to be choosen. When the user exits the spreadsheet an email is automatically sent to three different individuals based on what was choosen in column D. I.E. If "Grp1" was choosen person A, B, and C gets and email notifying them that they need to do something. When "Grp2" is choosen then person D, E, F are notified. And so o...

Help with a new "Aggregate Notes" form
Hi Everyone, Hopefully you can help me out here. I'm looking for an elegant solution to an obtuse problem. Our sales guys enter notes via their company contacts in CRM 4. However, when someone is looking for an overview of the activity on the account, because the notes are at the contact level - they have to drill down to view them. What I would like to do is introduce a new form that would be listed on the left hand side of the "Company" form, in the details section (in with activities, sub-accounts, contacts, etc...) that acted as a "Notes Aggregator", simila...

Selecting alternate rows
I have a large file (Excel XP) with about 300+names and related details. I need to break it into 2 files but I need to select alternate rows for each file. It may come out to every 3rd row to work into 3 files. Is there a quick way to do this rather than tediously select each alternate row, copy to the new file and delete from the old file? Many thanks for your help. Norm. Many thanks - I shall give it a go. If I have a problem, I'll get back to you. Norm. "B. R.Ramachandran" wrote: > Hi, > > You can break your data into two worksheets as follows: > >...

Need Your Help ASAP With SendObject Error
I have an Access 2002 database which is accessed by multiple users at different locations. The SendObject command, (DoCmd.SendObject acSendReport, stDocName, acFormatSNP, stToName & ", ", "John Doe" & ", ", , stMailTxt, , False), is used to email a Snapshot format of reports via Lotus Notes. It has worked fine for the last two years with users running Access 2002 version (10.6501.6817 SP3) and Lotus Notes version 6.5.2. Recently, some users at a remote location have received new pcs which upgraded them to a newer version of Microsoft Office (Access...

Information Store email corruption Or Veritas backup? Maybe? Help?
I am trying to find out what part is failing and who to go to. I want to find out what more I can do to check my Information Store. Question. What else can I do to check my Information Store? I have run ESEUTIL /d (No Errors) ESEUTIL /g (No Errors) ISINTEG -fix (No Errors) Back Ground Info: 1=2E I am having problems some users mail not backing up via backup exec 10d. Veritas says that it is an Exchange problem but I can't find any. I am getting al ot (HUGE amount) of errors. MS says it is a Veritas error... Example 1: WARNING: "\\EXCHANGE\Microsoft Exchange Mailboxes\Tom Ruck [T...

new email activity from a case default recipient
The default recipient for an email activity opened in a case is the account. This would be much more useful as the responsible contact since this is the most likely recipient of a case email response. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.micros...

i need to format a column as microseconds ? how do i do this
i need to format a column as microseconds ? how do i do this eg : hh:mm:ss.___ Format>Cells>Custom In the Type box, enter hh:mm:ss.000 -- Kind Regards, Niek Otten Microsoft MVP - Excel "SMT" <SMT@discussions.microsoft.com> wrote in message news:CF0BAF0B-FEC9-46CD-9784-3FDBEBA6729F@microsoft.com... >i need to format a column as microseconds ? how do i do this > eg : hh:mm:ss.___ ...

Urgent Help #4
Okay here is a sequence of events that have led to a bad situation that I can't solve. User account logon was set to NAME Use account logon was renamed to NAME.SURNAME POP Mail was then configured to be delivered to the MAILBOX OF NAME (NAME.SURNAME did not exist in list of options) Logon to NAME.SURNAME and no mail existed Use account logon was renamed back to NAME Logon and no mail existed but was starting to recieve new mail It would now appear that the mail that went in to the "black hole" is in the system mailbox that is not openable. What can I do???? Help please. ...

Help #25
I own a small moving company, and I am looking for a program that will allow me to give faster quotes. I need some thing where I can give each piece of furniture a certain code and save a price for that code, and when I enter all the different types of furniture it will calculate the total of all the pieces for me. If any one has any ideas of what I could use please email me at: 2MOVERS.COM@OPERAMAIL.COM Thanks Tyrone Hi Tyrone if you'ld like to email me direct (julied_ng at hcts dot net dot au) i'll be happy to send you a workbook that might give you some ideas. Cheers Juli...

Report Footer Help Needed Please
I have a report (a bill of lading) that I want to print 4 copies of. But at the bottom of each page I need a different statement printed (1st copy - "Original", 2nd copy "Customer Copy", 3rd copy "File Copy", etc.) Can anyone guide me in the right direction to accomplish this? Duane: Thanks for your quick response. I tried this, but I can not get it to work. Any other suggestions? Thanks, T "Duane Hookom" <duanehookom@NO_SPAMhotmail.com> wrote in message news:988241CB-1FD8-4EA7-98AD-7310A005CAA2@microsoft.com... > Allen Browne has a ...

HELP: "Delete Team" Privilege
Hi, I'm new to MS CRM. The default installation of MS CRM does not provide a privilege to delete a team in any of the roles (some other privileges missing as well). The manual states that the sysdamin should enable this privilege. How can this be done? What am I missing? Thanks for your help! Andrew ...

help with combo box display...plz...
i have a multicolumn combo box...with columns FName, MName, and LName...how can i enable it to display the 3 values of the column when a row is selected?? it's like that i'm merging the 3 values int the text box display of the combo box...please....thank yu -- ai® On Fri, 20 Apr 2007 08:30:20 GMT, ai_enjoi wrote: > i have a multicolumn combo box...with columns FName, MName, and LName...how > can i enable it to display the 3 values of the column when a row is selected?? > it's like that i'm merging the 3 values int the text box display of the combo > box......

column/block/rectangular selection of text in Word 2008
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel What happened to the ability to select a column/block/rectangular selection of text by holding down the alt/option key in Word 2008? How do I make a vertical text selection? <br> Thanks in advance. <br> JBM "Nothing" and "The Same Way" :-) However various things may get in the way: Spaces is one, having the Toolbox open is another. Anything that distracts the focus from the document page can potentially interfere with the operation of this function. As usual, the ...

select all for check box..
HI.. I have a check box field in a continuous form... name is mCheck I want to have a command button Select All such that when clicked, all check boxes in the continuous form would be selected...Thank you.. -- ai® Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200802/1 A continuous form would display a set of records. Are you saying that you want all the records in the set marked with a check-mark? If so, one way to do this would be to run a query via code behind the command button that updates the field underlying the checkbox in a...

In offline mode, need send/receive twice
I have a customer and he has a strange issue in outlook. He uses XP, Outlook2002 and exchange server. When he use "connect" mode, everything is OK. When he use "work offline" mode, he has a problem. After he create a new mail, click "send" button, this mail goto outbox.(It is normal process) Then he click "send/receive" button or F9, but this mail still in his outbox, no send out. He need to double click this mail to open again, click "send" button again. Then click "send/receive" button again, this time this mail can send out. So...