Results 1 to 8 of 8
  1. #1
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568

    check if more then one record is selected within subform

    Hi,

    I have multisearch subform.

    User can input value into unboud textbox, click button Search and subform will be requery with choosen results.
    Next i want to give users possibility to click button "Add" and show choosen record (with all fields) in other unbound texboxes.



    It is possible to check if user selected only one row or more ? (if more, mgsbox will be displayed).

    Please help,
    Best Wishes,
    Jacek Antek

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    i think access will present only 1 value if you ask:
    msgbox subform.form.txtBox

    no matter how many rows the user selects.

  3. #3
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    It is true (access will show values from 1 record of selection) but i want prevent user for doing that.
    Sometimes user may not see accidentally that they choosed bad record.

    Best Wishes,
    Jacek

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    So the subform is a continuous form showing multiple records? And you are worried they will select 2 records before hitting your add button which you say opens another subform or puts the values in unbound fields on the Main form? The Add button is on the main form or subform?

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    What I can't figure out is, when the user clicks off the form where they have selected records, how would one maintain that selection when clicking on some part of the main form, or even another part of the same subform?? I don't think you can do this without providing a static selector, such as a checkbox. As soon as you click on your command button the selection will be no more.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    Learned something today (again). Trick is to not put the event on the subform but rather the subform control, and that event would be the Exit event:
    Code:
    Private Sub Child5_Exit(Cancel As Integer) 'child 5 is the name of the subform control
    If Forms!MyFormName!Child5.Form.SelHeight > 1 Then
       MsgBox "Can only select one record."
       Cancel = True
    End If
    
    End Sub
    However, the subform selection will still be deselected when any control on the main form is clicked, so some handling of the selected record will have to be done in the same Exit event, such as getting Forms!MyFormName!Child5.Form.CurrentRecord.

  7. #7
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Hi Guys,

    thank you for all your tips and help.
    Micron method is working !

    Subform is datasheet view form.

    Now, mouse_up event is triggering Micron code and show msgbox where user select more then 1 record.

    Best Wishes,
    Jacek

  8. #8
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    Glad we could help. Good luck with your project!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 16
    Last Post: 02-13-2016, 10:21 AM
  2. Replies: 1
    Last Post: 03-31-2015, 05:17 AM
  3. Replies: 2
    Last Post: 03-03-2015, 07:20 AM
  4. Replies: 2
    Last Post: 07-09-2014, 04:28 AM
  5. Replies: 2
    Last Post: 07-24-2011, 08:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums