Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Apr 2005
    Location
    Walnut Creek, California, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access VBA (2000)

    Given a table containing the field names in another table opened as rstField and the second table as rst
    strCtrl2 = rstField!FieldName
    Debug.Print strCtrl2
    strCtl = "rst!" & strCtrl2
    Debug.Print strCtl
    Debug.Print rst!mLname
    Debug.Print Eval(strCtl)
    result is:
    mLname
    rst!mLname
    Winslow

    Does anyone have an idea why debug.print Eval(strCtl) returns:
    Error message "can't find the name 'rst' you entered in the expression

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,613
    Thanks
    3
    Thanked 58 Times in 58 Posts

    Re: Access VBA (2000)

    Welcome to Woody's Lounge - we hope you find it a friendly place to get answers to all things Office, Windows, etc.

    You don't show declarations for your code, but this sort of thing is usually the result of a missing declaration, and I suspect the actual error is coming from the line
    <font color=blue><font face="Georgia">Debug.Print rst!mLname</font face=georgia></font color=blue>
    In the grand scheme of things, rst is often used as the name of a recordset - do you have it declared as such?
    Wendell

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

    Re: Access VBA (2000)

    VBA can resolve variable names in Eval, but apparently not expressions involving DAO objects.

  4. #4
    New Lounger
    Join Date
    Apr 2005
    Location
    Walnut Creek, California, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access VBA (2000)

    The declarations are there I just didn't show them to keep things simple. I think HansV is right. I found a workaround although it 's not so elegant. When pushing the envelope sometimes it folds.

Posting Permissions

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