Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2003
    Posts
    138

    Unanswered: IIf VB statements

    Here's a question:

    Using VBA, is it possible to take a field, i.e. Type of Observation, which uses checkboxes with values of 1 - 6, and put the label that coincides with that check box value in an adjacent field.

    I.E. if it says Type of Observation is 1, then I want the adjacent field to say Participating in meeting, etc.

    and so on and so forth...

    Kind of like an IIf statement.

    i.e. IIf([Type of Observation]=1, "Participating in Meeting", Null)

    Thanks!

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    I would use a SELECT CASE construction in this case.

    Code:
    SELECT CASE [Type of Observation]
        CASE 1
            Label.Caption = "Participating in meeting"
        CASE 2
            Label.Caption = "...
        CASE ...
    END SELECT
    If the numerotation of the options is contiguous and begins at 1, you could also use the Choose function:
    Code:
    Label.Caption = Choose([Type of Observation], "Participating in meeting", " ... )
    Have a nice day!

  3. #3
    Join Date
    Dec 2003
    Posts
    138
    Thanks I'll try that!

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I wouldn't hard code that. Observation types probably belong in their own table with a friendly name/description.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Dec 2003
    Posts
    138
    I do have a separate table that lists the values, but how do I get that to show up in the new query?

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by Teddy
    I wouldn't hard code that. Observation types probably belong in their own table with a friendly name/description.
    +1

    Just join the table to your current query and add the column.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Dec 2003
    Posts
    138
    I tried that, however, it doesn't show up in the new query that the VB code creates, even though the information is supposedly pulled from that query. Let me try once more.

  8. #8
    Join Date
    Dec 2003
    Posts
    138
    Ok, I fixed my problem. My VB wasn't picking up the info from my query, which I'd created correctly, but my original table. So once I fixed that, everything else seems to be falling into place.

    I guess sometimes the answer's so simple we miss it. Thanks for your help!

Posting Permissions

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