• Limit selection to one record (Access97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Limit selection to one record (Access97)

    Author
    Topic
    #453569

    I have a form, (frmArchive) with a continuous form subform which has many abbreviated, uneditable fields. Each record has a checkbox (fldSelect) which is the only editable field on this form. At the bottom of the main form are 4 command buttons EditSelected, DeleteSelected, PrintSelected and ReturnToMainMenu. To be able to select and delete or select and print one or more records works properly. What I have been unable to figure out is how to limit a selection for the EditSelected to one record. The single record will be queried into another full page form to edit the many detailed fields. Is there a way with maybe a message box to prevent the user from selecting more than one record? Thank you.

    Viewing 0 reply threads
    Author
    Replies
    • #1123676

      You could count the number of ticked check boxes and issue a warning when the count is not equal to 1.
      Or you could have the Edit command button ignore the check boxes and use the active record instead.

      • #1123679

        What method could I use to count the number of ticked check boxes?
        Thanks
        Ron

        • #1123682

          Try

          Abs(Sum([fldSelect]))

          • #1123789

            My programming expertise is limited to DoCmd, Me, and similar type statements. Have been running into a brick wall with syntax errors trying to get the correct MsgBox to appear. A totals query was created to give a count of the selected records by returning a number result. This query result is named CountOffldSelect. Within the On Click Event Procedure of a command button I have inserted the following:

            If (CountOffldSelect) = 1 Then
            MsgBox “This is One Record”
            Else
            MsgBox “You Must Select Only One Record To Edit”
            EndIf

            This appears logical to me but is unacceptable to Access. This always evaluates to the Else. Any help would be appreciated. Thanks.

            Ron

            • #1123794

              I assume that the totals query is not the record source of the form. If so, you can’t directly refer to a field from this query. Let’s say the totals query is named qryCount.
              Try this:

              If DLookup(“CountOffldSelect”, “qryCount”) = 1 Then

            • #1123804

              That did the trick. Thank you very much.

              Ron

    Viewing 0 reply threads
    Reply To: Limit selection to one record (Access97)

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

    Your information: