Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to Determine if Current Object is a Form? (a2k (9.0.6926) SP-3 Jet 4.0

    If I have a form open and I run the following command:

    <pre>Function Menu_DesignView()
    On Error GoTo Error_Handler

    DoCmd.RunCommand acCmdDesignView

    Exit_Function:
    Exit Function

    Error_Handler:
    MsgBox "Error: " & Err.Description & " (" & Err.Number & ")"
    Resume Exit_Function

    End Function
    </pre>


    What test can I perform to determine if it is a form, query, etc?

    Thanks, John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to Determine if Current Object is a Form? (a2k (9.0.6926) SP-3 Jet

    What are you trying to accomplish? End users shouldn't open database objects in design view.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to Determine if Current Object is a Form? (a2k (9.0.6926) SP-3 Jet

    I

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to Determine if Current Object is a Form? (a2k (9.0.6926) SP-3 Jet

    Charlotte's reply tells you what you need.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to Determine if Current Object is a Form? (a2k (9.0.6926) SP-3 Jet

    Right on Charlotte

    If Application.CurrentObjectType = 1 Then '1=query, 2=form
    DoCmd.RunCommand acCmdDatasheetView
    End If

    Thanks, John

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How to Determine if Current Object is a Form? (a2k (9.0.6926) SP-3 Jet

    Application.CurrentObjectType will return a number representing the type of active object and Application.CurrentObjectName will give you the name of it, if that helps. What exactly do you want to do? Are you trying to determine what kind of object was opened in design view as a result of the RunCommand?

    Here's a list of the types:

    <table border=1><td>Type</td><td>Object</td><td>1</td><td>Local Table</td></tr><td>4</td><td>SQL Server Table</td><td>5</td><td>Query</td><td>6</td><td>Attached Table</td><td>-32766</td><td>Macro</td></tr><td>-32761</td><td>Module</td><td>-32764</td><td>Report</td></tr><tr><td>-32768</td><td>Form</td><tr></table>
    Charlotte

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How to Determine if Current Object is a Form? (a2k (9.0.6926) SP-3 Jet

    I modified my post to include a list of the type values, John.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •