Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Placing a variable value in place of object name (Access 2000)

    I need the following to work where the object name is stored in a variable.

    var1 ="Object Name"

    Me.[object name].Value = Me.txt_Parameter_1.Value

    Please Help

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

    Re: Placing a variable value in place of object name (Access 2000)

    If you want to refer to a control on a form or report, you can use

    Me.Controls(var1) = Me.txt_Parameter_1.Value

  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Placing a variable value in place of object name (Access 2000)

    I have a similar need in which I want to set the properties of a control referenced by a variable and to also pass it to a function which is expecting a control as the argument. This syntax doesn't support either and I haven't been able to come up with the correct derivative form.

    Thanks for your help.
    Marty

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

    Re: Placing a variable value in place of object name (Access 2000)

    It is very well possible to pass a control as argument to a procedure or function. Please provide some details.

  5. #5
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Placing a variable value in place of object name (Access 2000)

    Hans,

    I've a report with a series of boxes drawn over an image of townhome development map. I'm attempting to set the properties of each box (line style, line width and line color) based on the values in the underlying report table. I don't print the actual table values values, only their representation through the boxes. The table contains one record with a field for each box . The table field names and report box names are identical. Following is the code where I've atttempted to set the report legend boxes:

    Dim ctlTitle As Control, ctlStyle As Control, ctlWidth As Control, ctlColor As Control

    For i = 1 To 6
    Set ctlTitle = Me("Condition" & Format(i, "00") & "Title")
    Set ctlStyle = Me.Controls("Condition" & Format(i, "00") & "LineStyle")
    Set ctlWidth = Me.Controls("Condition" & Format(i, "00") & "LineWidth")
    Set ctlColor = Me.Controls("Condition" & Format(i, "00") & "LineColor")

    If IsNull(ctlTitle) Then
    ctlTitle.Visible = False
    Else
    ctlTitle.Visible = True
    SetAttributes False, ctlTitle, ctlStyle, ctlWidth, ctlColor
    End If
    Next i

    I've successfully tested the concept where I've not used variables for the field names. However, with over 250 boxes I don't want to do it this long way, but rather with a couple of sets of loops like the one above.

    Thanks for your help,
    Marty

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

    Re: Placing a variable value in place of object name (Access 2000)

    <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    You have controls named Condition01LineStyle, Condition03LineWidth, Condition06LineColor etc.?
    Where does the table come into this?

    <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

  7. #7
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Placing a variable value in place of object name (Access 2000)

    The underlying table has the condition titles and box line properties as set by the user. It also has the condition value for each building/unit or other structure which has a cooresponding box on the report.

    For the legend, Condition01Text displays the text of the condition. There can be 5 additional conditions - 2 thru 6 (for example: NA, Needs Immediate Replacement, Poor, Average, Near New and New). For each condition, the user gets to set the way it is to be displayed in the report, i.e line style, line width and line color. These line properties are then set for each of the 200+ other boxes representing building addresses based on the condition value in the underlying table for each address/box. The condition value for each address has been set elswhere. This report has boxes for each of the numbered units in a building as well as boxes for numerious other structures. This was accomplished with straight field/control assignments for each of the 35 buildings ...

    If IsNull(Me!Condition01Title) Then
    Me!lctlCondition01Title.Visible = False
    Else
    Me!lctlCondition01Title.Visible = True
    SetAttributes False, Me!lctlCondition01Title, Me!Condition01LineStyle, Me!Condition01LineWidth
    End If

    If IsNull(Me!Condition02Title) Then
    Me!lctlCondition02Title.Visible = False
    Else
    Me!lctlCondition02Title.Visible = True
    SetAttributes False, Me!lctlCondition02Title, Me!Condition02LineStyle, Me!Condition02LineWidth
    End If
    etc, etc. In my attempt to use variables for the field names, I've also added the color property.

    Marty

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

    Re: Placing a variable value in place of object name (Access 2000)

    I'm afraid I can't help you, I don't understand this at all. You haven't told us what SetAttributes is, and I still don't know what the table has to do with this.

  9. #9
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Placing a variable value in place of object name (Access 2000)

    Hans,

    I apologize for not being able to communicate any more clearly than I have. I

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

    Re: Placing a variable value in place of object name (Access 2000)

    If the "long" code works, the "short" code should work too. Do you actually have controls named Condition01LineStyle, Condition01LineWidth etc. on the report?

Posting Permissions

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