• Populate string from option array (Access 97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Populate string from option array (Access 97)

    Author
    Topic
    #413807

    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.

    Viewing 1 reply thread
    Author
    Replies
    • #915582

      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..

      • #915586

        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.

        • #915592

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

          • #915594

            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

            • #915602

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

            • #915620

              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.

            • #915622

              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.

            • #915626

              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! cheers

            • #915627

              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! cheers

            • #915623

              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.

            • #915621

              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.

            • #915603

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

          • #915595

            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

        • #915593

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

      • #915587

        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.

    • #915583

      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..

    Viewing 1 reply thread
    Reply To: Populate string from option array (Access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: