Results 1 to 9 of 9
  1. #1
    csh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    3

    GO TO buttons on form


    I'm new to access and need some help. I have two forms based on a single table. One shows a list of records (with a few fields), the other in a single record with several fields. I'd like to create a button on each line of the record list form that will open the individual record on the single record input form. Also would like to have a button on the single record that would take me back to the list form. Help!!- ( and thanks!)

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Why not make the second form a subform of the first. Look at this video and it may help you achieve what you are looking for.

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

    Alan

  3. #3
    Toyman is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    233
    Quote Originally Posted by csh View Post
    I'm new to access and need some help. I have two forms based on a single table. One shows a list of records (with a few fields), the other in a single record with several fields. I'd like to create a button on each line of the record list form that will open the individual record on the single record input form. Also would like to have a button on the single record that would take me back to the list form. Help!!- ( and thanks!)
    On your list form, create one single field for the primary key from the table in the header section of the form. This is so that each field you click on will display the primary key for that record in the single primary key field of the form. Create a button on top of the form. In the button, put the follow code in the on click event of the button:

    Docmd.OpenForm "YourSingleFormName", AcNormal

    So, when you want to open the single record form, put the cursor on the record in which you want the single record form to open to.

    In the single record form, put the follow sql statement in the recordsource for the form.

    "Select * From YourTableName Where YourPrimaryKeyName = [Forms]![PrimaryFieldName]"

    The [Forms]![PrimaryFieldName] points to the primary field name of the list form. What happens is that when the single form opens, the sql for the recordsource opens to the record that matches the primary key field of the list form. You can just leave the list form open under the single record form. This way, when you close the single record form, the list form will be available. This will save the trouble of having the user click another button to open the list form.

  4. #4
    csh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    3

    Alan thanks for your time

    As I mentioned, I'm still a bit of a novice and I'm still having trouble. The primary key field on my table is " Distributor Name " and the table name is " Distributors ". The name of my single record form is " Distributor Detail ". Based upon your input, I typed the following into the resource source:

    "Select * From Distributors Where Distributor Name = [Forms]![Distributor Name]"

    When I try to return to form view, I get an error indicating that the source is incorrect. Did I type it correctly (including spaces) Any thoughts?
    Thanks-

  5. #5
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    Try "Select * from Distributors Where [Distributor Name] = [Forms]![FormName]![Distributor Name]

    You need to add your form name to the last part of the query. Also it's a good idea to use a naming convention so you aren't getting the same name used where it could be found in multiple locations.

    Example: For forms, use frm_formname, for text fields on a form, use txt_fieldname, etc.

    Ideally you should do that for tables as well, but that is just me being ornery and nit picking.

    I would like to see "Select * from tbl_Distributors Where [tbl_Distrubtors].[Distributor Name] = [Forms]![frm_Main_Form]![txt_Distributor_Name]. (Note that I left the original field name in there just to prove I am not an absolute freak, just a minor one.)

    Hope this helps...

  6. #6
    Toyman is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    233
    Quote Originally Posted by csh View Post
    As I mentioned, I'm still a bit of a novice and I'm still having trouble. The primary key field on my table is " Distributor Name " and the table name is " Distributors ". The name of my single record form is " Distributor Detail ". Based upon your input, I typed the following into the resource source:

    "Select * From Distributors Where Distributor Name = [Forms]![Distributor Name]"

    When I try to return to form view, I get an error indicating that the source is incorrect. Did I type it correctly (including spaces) Any thoughts?
    Thanks-
    Since your primate key "Distributor Name" contains seperate words, you need to enclose them in brackets

    "Select * From Distributors Where [Distributor Name] = [Forms]![YourSourceFormName]![Distributor Name]"

    My mistake, I left out the reference form name in the sql statement

  7. #7
    csh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    3

    Thanks Guys!

    I tried both of your suggestions regarding modifying the SQL statement in the recordsource and couldn't get it to work. I'm sure I did something wrong. However, I was able to figure out the (in retrospect) simple navigation button command to go to the individual form I wanted and return to the main list. I just needed to work thru the button set-up wizard. Thanks again!-csh

  8. #8
    hitesh_asrani_j is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    75
    One question here.... If I name my form name as "frm_asda" then the heading when it opens also it shows the same :| can i change that?

  9. #9
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    With your form open in design view, go to properties, format, caption.

    BTW. You should not hijack someone else's thread. You should start a new thread for an unrelated question

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

Similar Threads

  1. Buttons on form to navigate through records
    By emilyrogers in forum Forms
    Replies: 2
    Last Post: 07-19-2011, 10:17 AM
  2. Buttons activating on form startup
    By howieyo in forum Forms
    Replies: 0
    Last Post: 06-13-2011, 06:48 PM
  3. Replies: 1
    Last Post: 06-01-2011, 06:44 PM
  4. Web Database Form Buttons No Wizzard!!!
    By tucker1003 in forum Forms
    Replies: 4
    Last Post: 05-04-2011, 08:56 PM
  5. Form and Buttons
    By rmohebian in forum Forms
    Replies: 1
    Last Post: 02-14-2011, 09:57 AM

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