Results 1 to 5 of 5
  1. #1
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265

    Returning the object type of an object

    When I run the following code, it returns “109” which representsa textbox. Here, txtDisplay is atextbox. I was hoping it would return thewords “Text Box” in the dialog window.



    MsgBox txtDisplay.ControlType

    I am trying to find a method, that can:

    1. Return the object type of an object withoutusing the code above, or
    2. Return the object type of an object using thecode above


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    You already know how to do 2.

    Exactly what do you want to accomplish? Why do you need to know object type?
    Last edited by June7; 06-07-2019 at 01:46 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    have seen this before. IIRC, you would need to include a list of constants in your code and return those. However, your example suggests you're using a method of control naming that ought to make it apparent to you, so you must have some undisclosed reason why that isn't good enough.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You can use this structure

    Code:
     Debug.Print frm.Name & " | " & ctl.Name & "(" & TypeName(ctl) & ")" & " --" & ctl.Tag
    In my example code from a recent post I get the following output for controls on 2 forms:

    customer | Text214(TextBox) --
    customer | Label215(Label) --
    customer | Command222(CommandButton) --
    customer | Command429(CommandButton) --
    customer | Combo224(TextBox) --
    customer | Label225(Label) --
    customer | Command210(CommandButton) --
    customer | ID(TextBox) --Audit
    customer | ID_Label(Label) --
    customer | Form Code(TextBox) --Audit
    customer | Form Code_Label(Label) --
    customer | Form Name(TextBox) --Audit
    customer | Form Name_Label(Label) --
    customer | Process(TextBox) --Audit
    customer | Process_Label(Label) --
    customer | User BU(TextBox) --Audit
    customer | User BU_Label(Label) --
    customer | Command168(CommandButton) --
    customer | Author(TextBox) --Audit
    customer | Author_Label(Label) --
    customer | Command441(CommandButton) --
    FormName -- ControlName{controlType}

    frmCommentsJDraw | Label6(Label) --
    frmCommentsJDraw | ID(TextBox) --
    frmCommentsJDraw | ID_Label(Label) --
    frmCommentsJDraw | Comment(TextBox) --
    frmCommentsJDraw | Comment_Label(Label) --
    frmCommentsJDraw | CommentDate(TextBox) --
    frmCommentsJDraw | CommentDate_Label(Label) --


  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    typename(forms!formName.contolName) works in immediate window.
    The named constants thing I read in the past might not have been about control types.
    Thanks!

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

Similar Threads

  1. Replies: 7
    Last Post: 05-23-2019, 07:18 AM
  2. Replies: 2
    Last Post: 07-20-2017, 07:20 AM
  3. Replies: 4
    Last Post: 05-02-2016, 04:33 AM
  4. Replies: 1
    Last Post: 09-03-2011, 07:01 PM
  5. Replies: 1
    Last Post: 08-05-2010, 12:11 PM

Tags for this Thread

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