Can a string variable be used as a line of code in VB?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dan Cain
    New Member
    • Feb 2011
    • 1

    #1

    Can a string variable be used as a line of code in VB?

    I Dimmed a string variable and then built a line of code which I set equal to the variable. Is there a way to now use that variable as a line of VB code?

    Code:
        If Me.chkPris4None And Me.chkPris4Lac Then
            Call Correction("Pris", "4")
            GoTo Leave
        End If
    
    Private Sub Correction(kind, pers)
        Dim retval As String
        MsgBox "Can't have 'None' AND injury box checked.", vbOKOnly, "Data Error"
        retval = "me.chk" & kind & pers & "None = 0"
    End Sub
    Last edited by Stewart Ross; Feb 7 '11, 09:14 PM. Reason: corrected end code tag
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Code can't be set in a string!
    Why do You want to set a code in a string?
    In retval there is only the TEXT = "me.chkPris4Non e = 0".
    Nothing can reset this to a code.

    Comment

    Working...