How to use a variable to get a controls value.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kev

    How to use a variable to get a controls value.

    Hello All,
    I am attempting to use the variable "AccAllow " which is populated by
    opening a recordset. I am using AccAllowed to refer to a control on
    the active form (the Switchboard) but I am having difficulty with the
    syntax.
    AccessAllowed is a text field in the Switchboard items table. I am
    trying to modify the HandleButtonCli ck function in the Switchboard
    form. The AccessAllowed field is the name of one of many hidden text
    controls on the Switchboard form. This control's value is either a 1
    or 0 not "1" or "0"

    Could someone please help.? I am not sure what I should be declaring
    the AccAllow variable as.

    Dim dbs As Database
    Dim rst As Recordset
    On Error GoTo HandleButtonCli ck_Err
    Dim AccAllow As Variant

    Set dbs = CurrentDb()
    Set rst = dbs.OpenRecords et("Switchboar d Items", dbOpenDynaset)

    rst.FindFirst "[SwitchboardID]=" & Me![SwitchboardID] & " AND
    [ItemNumber]=" & intBtn
    AccAllow = "Me!" & rst![AccessAllowed]

    Select Case rst![Command]

    ' Go to another switchboard.
    Case conCmdGotoSwitc hboard

    If AccAllow = 1 Then
    Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rst!
    [Argument]
    Else
    MsgBox "you don't have access to this function"
    Exit Function
    End If



    Cheers Kevin
  • Kev

    #2
    Re: How to use a variable to get a controls value.

    For anyone interested, the solution was simple - Bobby Heid came up
    with the answer

    I needed to replace this line

    AccAllow = "Me!" & rst![AccessAllowed]


    with this line

    AccAllow = me(rst![AccessAllowed])

    Regards
    Kevin

    Comment

    Working...