Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Populate string from option array (Access 97)

    I need to populate a string field from a list of option buttons.
    I can put in the necessary validation (first-no selections allowed from both areas
    second- <= 5 from the selection group) after the initial design is laid out.
    How would I go about creating this string?
    I've attached the form.

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

    Re: Populate string from option array (Access 97)

    Why use a text field? It's much easier to use a number of Yes/No fields - one for each check box. Or use a second table, with a record for each check box..

  3. #3
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate string from option array (Access 97)

    I originally intended to use a separate table but the data has to be saved to a comma delimited string in the main table for export.
    Technically, I could still use the separate table for the form and place an "update"button which saves the value to a string,
    but I really need the validation option to stop a user from entering values in both sets of options.
    Without that control array, I dont see that as possible.

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

    Re: Populate string from option array (Access 97)

    So what would you like the text field to look like?

  5. #5
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate string from option array (Access 97)

    Each button has a value like 1="BG" 2 ="RW" et al.
    Then I need to create the string into a simple comma delimited string.
    like str= "BG,RW" etc

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

    Re: Populate string from option array (Access 97)

    And how do you want to distinguish between the codes and violations of the same name?

  7. #7
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate string from option array (Access 97)

    Ah, interesting observation. This is actually just the same violation but with a warning flag set to true.
    There will never be warnings and violations. It's all of one group only-no mixed bags.
    I set it up this way because thats what the user wanted and basically had made.
    I guess I could redesign the form and load either a warning or violation form based on a user choice.
    How would I best start that string?
    Thanks for you help.

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

    Re: Populate string from option array (Access 97)

    Strictly speaking, you don't need two sets of check boxes then, just the single set with an additional check box that is"of" if they are warnings and "on" if they are violations. That way, you don't have to test that they're all in one group either.

    You can use code in the Before Update event of the form:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim strText As String

    If Me.chkBG Then
    strText = strText & ",BG"
    End If
    ...
    ...
    If Me.chkTO Then
    strText = strText & ",TO"
    End If

    If strText = "" Then
    Me.TextField = Null
    Else
    Me.TextField = Mid(strText, 2)
    End If
    End Sub

    Substitute the correct control and field names, and expand the ... as needed.

  9. #9
    4 Star Lounger
    Join Date
    May 2003
    Location
    Austin
    Posts
    401
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate string from option array (Access 97)

    Yep I just started that exact code. I think I wanted to stick to the original form so bad for fear of angering the boss. Sometimes you just have to go with your instincts and just tell them what is and is not possible. Thanks for all your help Hans! <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

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