Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access 2016 - Use a Button to Select a specific Record on a form

Posted on 2016-10-18
12
Medium Priority
?
317 Views
Last Modified: 2016-10-19
Greetings!
I want to link a form button(1) to open another form directly to a specific record associated with button(1)

I have attached my current efforts for review and input.

Thoughts?
Thanks!
Dennis

FormButtonInstructions-161018.JPG
0
Comment
Question by:DGWhittaker
  • 7
  • 4
12 Comments
 
LVL 18

Expert Comment

by:xtermie
ID: 41848025
I would suggest using a form-subform for that and not a button perhaps?
https://support.office.com/en-us/article/Create-a-form-that-contains-a-subform-a-one-to-many-form-ddf3822f-8aba-49cb-831a-1e74d6f5f06b

Can you describe what you are trying to do in more detail?
Or you just want everytime to open a specific form at a specific record via the button click?
0
 

Author Comment

by:DGWhittaker
ID: 41848045
I am working on a Launchpad with a logo for each of our dealerships.

The goal is to click on the logo for a specific dealership which will focus all the data specific to that dealership on the appropriate form or report being called.

Hope that helps,
Thanks!
Dennis
0
 
LVL 40

Accepted Solution

by:
PatHartman earned 2000 total points
ID: 41848564
You can use the Where argument of the OpenForm method

docmd.OpenForm "formname",acNormal,,"yourRecID = " & Me.yourRecID,acFormEdit,acDialog

When opening popup forms, I prefer to open them in Dialog mode to force the user to close them before going back to the main form.  This prevents confusion that sometimes occurs when multiple forms are open at one time or when the user goes back to the calling form and selects a new record.  He will not understand why the popup form didn't change records.  (You MUST close and then reopen the form to force it to show the new record)
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:DGWhittaker
ID: 41848976
Thanks Pat!
Lets see if I am following this in practice, if so I am still doing something wrong:

Am I am the right track with this?

FormButtonInstructions-161018-2.JPGThanks!
Dennis
0
 

Author Comment

by:DGWhittaker
ID: 41848983
My bad,
All is well,

I had the data stored as 70 instead of 70.
Thanks!
Dennis
0
 
LVL 40

Expert Comment

by:PatHartman
ID: 41849113
Are you sure you want to hard code the value of the store ID in the macro?  Why would you not pick it up from the current record in the form?
0
 

Author Closing Comment

by:DGWhittaker
ID: 41849275
Thanks Pat!
Dennis
0
 

Author Comment

by:DGWhittaker
ID: 41849281
Follow up question:

It makes sense to me that I would be able to name each of my logo buttons with the relative store number, then call that variable down the line to pull the appropriate data into a form or report based on which logo/button is selected.

If that is in fact true, how do I go about doing it?

Thoughts?
Thanks!
Dennis
0
 

Author Comment

by:DGWhittaker
ID: 41849284
HI Pat, just saw  your follow up question.

I am not sure of much outside of the vision I have of all the things I want to see this thing do eventually.
In the past, I designed all kinds of fantastic data systems in theory and by building mock ups in excel to hand over to others to build the actual applications.

Now I am building them myself, so I get to learn from good folks like yourself on how to make the magic come to life.

I believe I am on the right track by using a button name as a variable as noted above instead of hard coding it.

Thanks for all your help and support!

Thanks!
Dennis
0
 
LVL 40

Expert Comment

by:PatHartman
ID: 41850250
If you have multiple stores, I would use a combobox or perhaps an option group to select the store.  The combo is the most efficient since you simply pass the selected value to the macro.  If you add a new store, no code or form needs to be changed.  A new store simply shows up in the list.  The Option Group is more labor intensive since you would have to modify the option group manually if you add a new store.  This might be more visually appealing and it can be formatted with radio buttons, dots  or checkboxes,  The code is the same as it would be for a combo but with the exception that the option group only supports numeric IDs so if your stores don't have numeric IDS, you would need code behind the scenes to translate from a number to an actual store value.

My personal choice would be the combo because I hate to create interfaces that i know will have to change.
0
 

Author Comment

by:DGWhittaker
ID: 41850391
Thanks Pat!
I know that coming from a design background vs a coding background, my ideas and desires follow a more artistic vs. practical approach.

I really like the elegance that would come from a more intuitive user experience that would come if the user could simply click on the logo or employees photo as we drill down from the entire company performance down to a specific employees performance on these key metrics.

I agree with the simplicity of doing things that are completely data driven so no future system updates or mods are required.

Please let me know if you dream up a solution that would allow a balance between my desired state with a practical coding solution!

Thanks again for all the insights:)

Dennis
0
 
LVL 40

Expert Comment

by:PatHartman
ID: 41850443
The Option group is the middle ground.  It gives you some graphical representation but behind the scenes requires minimal changes to add new stores.

If you have three stores and are probably not going to add one for another year, then "buttons are beautiful".  If you are McDonalds and are adding stores every week, then buttons are silly.  One interface isn't better than the other.  You have to choose whatever is practical for the given situation.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question