Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Limit selection to one record (Access97)

    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.

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

    Re: Limit selection to one record (Access97)

    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.

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Limit selection to one record (Access97)

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

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

    Re: Limit selection to one record (Access97)

    Try

    Abs(Sum([fldSelect]))

  5. #5
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Limit selection to one record (Access97)

    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

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

    Re: Limit selection to one record (Access97)

    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

  7. #7
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Limit selection to one record (Access97)

    That did the trick. Thank you very much.

    Ron

Posting Permissions

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