Results 1 to 12 of 12

Thread: [RESOLVED] Control.TypeOf Question

Threaded View

  1. #4

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2015
    Location
    Finland
    Posts
    692

    Re: Control.TypeOf Question

    Thanks Bonnie, that is nice solution and more useable when there are several user controls in form.

    Other solution is to directly point with control name like;

    Code:
    If TypeOf C Is TextBox Or TypeOf C Is ComboBox Or UCase(C.Name) = "GRDORDERROWS" Then...
    Another question. I am doing dynamic sql clause by code, control name and it's data is dealt with part of the sql queries where clause. Control name is same as db field name and data is search key. Controls - ownerdrawn and/or created dynamically by controls.add method fex. UserControl.Controls.Add("VB.TextBox", "tbEdit")) in usercontrol, are not detected either with frm.Controls.

    So.. Opinions what is the elegant way to get the control name inside usercontrol?

    Controls are named after db fieldnames. I am thinking on putting field names to array, but if names could be read by code (public method inside usercontrol), then that is obviously unneccessary?

    Code:
    Public Property Get ucControl() As Object
        Set ucControl = UserControl.Controls
    End Property
    but calling it's data by
    grdOrderRows.ucControl.Text

    Generates 438 object does not support this method - error.
    So how to correct that? Tried with Set ucControl = UserControl.Controls.tbEdit, UserControl.Controls.TbEdit.Text and UserControl.Controls.TextBox.TbEdit.Text as per above example - no worky. Idea is to get the control name and it's data as per above.
    Last edited by Tech99; Aug 4th, 2015 at 07:02 PM.

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