Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Working on this, thought i'd ask around...

    I want to create a button that will load user edit controls with data from companion controls that only display preloaded data. one way to identify the preloaded controls is to add a tag to them, and this allows me to cycle thru and find the name/value pairs for the preloaded data.

    the fun begins when i try to assemble a control name in code and assign it the value fetched:

    [codebox]Private Sub btnValuesToUserEdits_Click()
    Dim UserCtlString As String
    Dim UserCtl As Control
    Dim ctl As Control
    For i = 0 To 7
    For Each ctl In Me.MainTab.Pages(i).Controls
    With ctl
    If .Tag = "OR" Then
    ControlName = .Name
    ControlValue = .Value
    UserCtlString = "UE_" & ControlName <-- this gives me a valid control name
    UserCtl = UserCtlString <-- this doesn't work
    UserCtl.Value = ControlValue
    End If
    End With
    Next
    Next i

    End Sub[/codebox]

    Essentially I want a variable that specifies an existing control, find the control and load it with the value in the tagged control. now, perhaps this is going to have to be some sort of array to load value/pairs and an additional array to step thru controls and map the values but i was hoping to do this in a single loop. no good reason, just seems a lot easier. That doesn't mean it can be done, of course...

    TIA

  2. #2
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    [quote name='steve_skelton13' post='799400' date='22-Oct-2009 19:14']Working on this, thought i'd ask around...

    I want to create a button that will load user edit controls with data from companion controls that only display preloaded data. one way to identify the preloaded controls is to add a tag to them, and this allows me to cycle thru and find the name/value pairs for the preloaded data.

    the fun begins when i try to assemble a control name in code and assign it the value fetched:

    [codebox]Private Sub btnValuesToUserEdits_Click()
    Dim UserCtlString As String
    Dim UserCtl As Control
    Dim ctl As Control
    For i = 0 To 7
    For Each ctl In Me.MainTab.Pages(i).Controls
    With ctl
    If .Tag = "OR" Then
    ControlName = .Name
    ControlValue = .Value
    UserCtlString = "UE_" & ControlName <-- this gives me a valid control name
    UserCtl = UserCtlString <-- this doesn't work
    UserCtl.Value = ControlValue
    End If
    End With
    Next
    Next i

    End Sub[/codebox]

    Essentially I want a variable that specifies an existing control, find the control and load it with the value in the tagged control. now, perhaps this is going to have to be some sort of array to load value/pairs and an additional array to step thru controls and map the values but i was hoping to do this in a single loop. no good reason, just seems a lot easier. That doesn't mean it can be done, of course...

    TIA[/quote]

    Firstly you would need to use set to assign to a control variable
    and you cannot just assign it a string it has to relate to the Forms Control Collection

    Try something like

    SET UserCtl = ME(UserCtlString) '<-- this ought to work
    Andrew

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks! worked like a charm.

Posting Permissions

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