Results 1 to 3 of 3
  1. #1
    jrockusa is offline Novice
    Windows XP Access 97
    Join Date
    Nov 2009
    Posts
    4

    Muliple If, Then Statements

    I have a form with certain fields that must run a different macro depending on what fields are selected.



    What I have below is working fine but I not completely accomplishing what is required. I would like the 2nd Macro to be dependent upon two fields being selected. I want the McrApprovedButz to run only if the Status field = Approved and the Manager Approval Name = James Butz. Could you please let me know what to adjust in my second example. There are actually 5 different managers and I want a different macro to run based on what Manager Approval Name is selected. Is this possble?

    Example 1 - Works fine

    Code:
     
     
    Private Sub CboStatus_AfterUpdate()
    If [Status].Value = "Completed" Then
    DoCmd.RunMacro "McrCompletedItem"
    
    ElseIf [Status].Value = "Approved" Then
    DoCmd.RunMacro "McrApprovedButz"
    End If
    End Sub
    Example 2 -

    Code:
     
     
    Private Sub CboStatus_AfterUpdate()
    If [Status].Value = "Completed" Then
    DoCmd.RunMacro "McrCompletedItem"
    
    ElseIf [Status].Value = "Approved"  and
    [ManagerApprovalName].Value = "JamesButz" Then
    DoCmd.RunMacro "McrApprovedButz"
    End If
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You had it!
    Code:
    Private Sub CboStatus_AfterUpdate()
       If [Status].Value = "Completed" Then
          DoCmd.RunMacro "McrCompletedItem"
       ElseIf [Status].Value = "Approved" And [ManagerApprovalName].Value = "JamesButz" Then
          DoCmd.RunMacro "McrApprovedButz"
       End If
    End Sub

  3. #3
    accessgenie is offline Novice
    Windows XP Access 2002
    Join Date
    Dec 2009
    Location
    Tampa Bay, FL
    Posts
    4
    Your 2nd example will work. However, since you have 5 managers, it might be simpler to use a Select Case statement such as:

    Code:
    Private Sub CboStatus_AfterUpdate()
    	If [Status].Value = "Completed" Then
    		DoCmd.RunMacro "McrCompletedItem"
    	ElseIf [Status].Value = "Approved"  Then
    		Select Case [ManagerApprovalName].Value
    			Case "JamesButz"
    				DoCmd.RunMacro "McrApprovedButz"
    			Case "JaneDoe"
    				DoCmd.RunMacro "McrApprovedDoe"
    			Case ... <Etc. for each manager>.....
    		End Select
    	End If
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Concatenation and IIF statements in report
    By bjsbrown in forum Reports
    Replies: 20
    Last Post: 10-19-2009, 10:00 AM
  2. Query for IIF statements
    By SpotoR1 in forum Queries
    Replies: 2
    Last Post: 08-26-2009, 06:57 AM
  3. IIF Statements
    By JDA2005 in forum Queries
    Replies: 8
    Last Post: 07-07-2009, 04:24 PM
  4. If statements
    By Ezeecopy in forum Access
    Replies: 0
    Last Post: 03-24-2009, 04:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums