Results 1 to 12 of 12
  1. #1
    LBB is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    6

    After updating a subform, how can I get the "Find Record" command button to search the Main Form?

    Hi



    After much searching and reading I think this could be something about GoTo, or SetFocus but I'm totally new to Access (and can't code) and am not really sure what to search for any more!

    I have built a simple database for recording sports coaches and their sessions. I have two tables, one for coach details (Name, Address etc), and one for their sessions (Date of session, Number of players who attended, topic taught).

    I've built a simple form/subform that brings up the coach name (mainform, stacked) and then all their session details (subform, tabular). The idea is to use this form every week to update the sessions subform with new sessions.

    To make it more user-friendly I'm using the built-in "Find Record" command button to search for the coaches.

    My issue is, once I've used "Find Record" to find a coach, and then updated the sessions in the subform, hitting that "Find Record" button again only searches the subform. How can I get the button, or something, to go back to searching the main form records? I essentially want a "Find Coach" button but don't know how to restrict where Access looks for records.

    Hope I've explained that ok...

    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Did you click back to the main form first before clicking "Find Record"? I am not sure what you mean by 'built-in Find Record button' - do you mean Find & Replace? I build my own search functionality. Anything other than 'built-in' will require code. Examples:

    http://www.datapigtechnologies.com/f...tomfilter.html

    http://www.allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    LBB is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    6
    Hi June7

    So when I add a Command Button, Access helpfully gives me a set of options - Save Record, Find Record, Go to New Record and so on. I wouldn't know how to build my own search box I'm afraid.

    I can click on the Main Form and then do a search, but I am trying to not have to do that. I'm looking for a solution that cuts out that step.

    Thank you

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I never use the code wizard and I don't use macros, only VBA.

    Would need code that sets focus back to a control on the main form. Maybe in the subform AfterUpdate event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    LBB is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    6
    Thanks, yes I read it might be something to do with the focus. Can you advise how I would do that as per your suggestion?

    Quote Originally Posted by June7 View Post
    I never use the code wizard and I don't use macros, only VBA.

    Would need code that sets focus back to a control on the main form. Maybe in the subform AfterUpdate event.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Sorry, subform AfterUpdate won't be useful for this.

    Is the subform set as Datasheet or Continuous view? You said 'sessions' - plural. This means multiple session records could be entered. How should Access know that you are done entering records and return to the main form?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    LBB is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    6
    The subform is in Datasheet view, and yes multiple session records can be entered.

    I am trying to tell Access I'm done entering records and ready to search the mainform again by creating/using a button. At the moment the button I have only searches the "active" part of the form, in this case, the subform.

    Quote Originally Posted by June7 View Post
    Sorry, subform AfterUpdate won't be useful for this.

    Is the subform set as Datasheet or Continuous view? You said 'sessions' - plural. This means multiple session records could be entered. How should Access know that you are done entering records and return to the main form?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I don't understand. If button is on main form to find a coach record on the main form, how could it be searching the subform?

    Really need to know the code in use. If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    LBB is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    6
    It searches the subform because a record had just been entered into the subform.

    As I said I don't know code, I am using Access's own function - you click an option in Form Design Tools to create a Command Button. You're then presented with a list of options for what the button does. I'm using the Action called "Find Record". When you use that button it looks like a standard Find/Replace dialog box, but it's not anything I have coded myself.

    Hope that makes more sense? Apologies if I'm not explaining very well.

  10. #10
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by LBB View Post

    Hope that makes more sense?
    Not really; you say the Subform is in Datasheet View, then you speak of creating a Command Button. Although, while in Form Design View, you can add a button to a Datasheet View Form, at runtime the button will not be visible, which is why June7 (as well as myself) assumed the button in question was on the Main Form. And if the button is on the Main Form, I have to repeat June7's question:

    Quote Originally Posted by June7
    If button is on main form to find a coach record on the main form, how could it be searching the subform?
    That question is asked because the fact that you're clicking a button on the Main Form means that the Focus has now moved to the Main Form, and the Find Button should be searching in the Recordset associated with that Form, not the Recordset associated with the Subform.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    LBB is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    6
    Thanks for your reply.

    Sorry if I am not using the terms well, still learning!

    Can you clarify, when you say is the button "on" the main form, it appears in the header, and the functionality is whatever the default functionality is.

    Here is a screenshot of where the button "is"... hope it comes through, I have very limited internet.

    From what I have read, I thought...
    the main form is the Coach/Field/Division bit
    the Coaches Sessions is a subform in Datasheet View
    the binoculars is a Find Record Command Button

    It's always visible whether I'm updating the top section or the subsection but when I'm in the subsection, clicking the button doesn't search the main form's table as I'd hoped.

    If you need any more info please let me know!
    Thank you.

    Quote Originally Posted by Missinglinq View Post
    Not really; you say the Subform is in Datasheet View, then you speak of creating a Command Button. Although, while in Form Design View, you can add a button to a Datasheet View Form, at runtime the button will not be visible, which is why June7 (as well as myself) assumed the button in question was on the Main Form. And if the button is on the Main Form, I have to repeat June7's question:



    That question is asked because the fact that you're clicking a button on the Main Form means that the Focus has now moved to the Main Form, and the Find Button should be searching in the Recordset associated with that Form, not the Recordset associated with the Subform.

    Linq ;0)>
    Attached Thumbnails Attached Thumbnails button.PNG  

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Suggest you provide db for analysis. Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 7
    Last Post: 11-30-2013, 12:33 PM
  2. Replies: 8
    Last Post: 11-26-2013, 12:21 PM
  3. Replies: 30
    Last Post: 09-27-2013, 01:34 PM
  4. Replies: 10
    Last Post: 03-15-2013, 05:46 AM
  5. Replies: 3
    Last Post: 02-23-2010, 06:32 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