Results 1 to 4 of 4

Thread: Get the type of a control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    belgium
    Posts
    74

    Thumbs up

    Hello,

    I've an application, which set several controls on the form at runtime.
    Now I want to put the value of the controls into a recordset. The problem is that I don't now what sort of control I'm retrieving the data from.
    For instance:
    With a simple textbox you can retrieve the data by object.TEXT,
    but with a checkbox for instance it is object.VALUE

    How can I get the type of the control, which contains the data?

    Thanks

  2. #2
    Junior Member
    Join Date
    Nov 2000
    Location
    Belgium
    Posts
    21

    Thumbs up

    I had the same problem.
    You can use :

    Select Case TypeName(Screen.ActiveForm.Controls(X))
    Case "TextBox", "MaskEdBox"
    ' your code
    Case "CheckBox"
    ' your code
    End Select




  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Also check out TypeOf

    Code:
    Private Sub CheckControl(ctrl As Control)
    Dim ctrl As Control
    Msgbox TypeOf ctrl Is CheckBox
    Msgbox TypeOf ctrl Is TextBox
    End Sub
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    belgium
    Posts
    74
    Hey JOP, thanks for helping me out.

    I found the code must easier then that from iring

Posting Permissions

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



Click Here to Expand Forum to Full Width