Results 1 to 2 of 2
  1. #1
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80

    DoCmd in a variable using Case Select


    I am trying to use a Case Select to determine whether to use DoCmd.OpenReport or DoCmd.OpenForm. If case 1, OpenReport, if case 2, OpenForm.

    I can get it to work with the report/form name but not the actual DoCmd.Open. Something like:

    Code:
                Case 1
        formtoopen = DoCmd.OpenReport "rptActionNeeded"
                Case 2
        formtoopen = DoCmd.OpenForm "frmSchedulerRoutine"

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Not sure what you mean...
    Code:
                Case 1
                    DoCmd.OpenReport "rptActionNeeded"
                Case 2
                    DoCmd.OpenForm "frmSchedulerRoutine"
    Is above what you want?

    OR

    Code:
    Case 1
        formtoopen = "rptActionNeeded"
    Case 2
        formtoopen = "frmSchedulerRoutine"
    Then later...
    Code:
    Select case Left(formtoopen,3)
        Case "rpt"
            docmd.openreport formtoopen
        Case "frm"
            docmd.openform formtoopen
    End Select
    Last edited by davegri; 09-21-2017 at 11:58 PM. Reason: More options

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

Similar Threads

  1. Pl sql case select
    By mrmmickle1 in forum Queries
    Replies: 1
    Last Post: 11-17-2015, 11:14 PM
  2. Replies: 6
    Last Post: 02-24-2014, 09:26 AM
  3. Select case help
    By killermonkey in forum Programming
    Replies: 7
    Last Post: 10-25-2013, 05:09 PM
  4. Replies: 4
    Last Post: 01-05-2013, 04:32 PM
  5. Replies: 3
    Last Post: 08-22-2012, 09:01 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