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

    Object Name used in a variable (Access 2000)

    How do I use a variable in say an Isnull() statement when the variable is the name of a text box. For example, this is not working:

    txtName = "txtStudy"

    for 1 = 1 to intHigh
    txtNameFull =txtName" & i

    if IsNull(txtNameFull.value) then
    msgbox("No data")
    end if
    next i



    Mike

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

    Re: Object Name used in a variable (Access 2000)

    You can refer to a control by its name as Controls("NameOfControl"). So you can use

    If IsNull(Me.Controls(txtNameFull)) Then

  3. #3
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Object Name used in a variable (Access 2000)

    so would this be correct?

    If IsNull(Me.Controls(txtNameFull).value) Then

    Thanks
    Mike

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

    Re: Object Name used in a variable (Access 2000)

    Yes, the Value property is the default property of a text box, so Controls(...) is equivalent to Controls(...).Value.

  5. #5
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Object Name used in a variable (Access 2000)

    That worked.

    Thanks Hans
    Mike

Posting Permissions

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