Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    berni3883 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    17

    command button

    Hi,

    How would I go about having a command button on a form to open another form to a specific record.
    I have tried and tried but cannot do so. The 2nd form open to the first record everytime.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    Does this help?

    BaldyWeb wherecondition
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    berni3883 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    17
    thank you for your reply. Where would I put that though? What I did was make a combo box on my form to list all the students on the second form. And then I have a command button that is supposed to take me to the selected student on my second form. But the command button wont do that.

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    That VBA code would go in the button's Click event.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    berni3883 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    17
    I am getting a syntax error? I have no idea what I am doing wrong.

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    Did you use the format appropriate to the data type of the field?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    berni3883 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    17
    yes the field is text so i used the text format. I copied and pasted what you had and replaced the form name, field name, and control name

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    What exactly is your code?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    berni3883 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    17
    DoCmd.OpenForm "Student Form", , , "Student Name = '" & Me.Student Name & "'"

  10. #10
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    The inadvisable spaces will require you to bracket names. Try:

    DoCmd.OpenForm "Student Form", , , "[Student Name] = '" & Me.[Student Name] & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    berni3883 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    17
    The syntax error is still popping up

  12. #12
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    berni3883 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    17
    It is too large for me to upload. is there another way I can attach it?

  14. #14
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    If you compact/repair and then zip, most db's will be small enough. If not, email it to

    pbaldy
    gmail
    com
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    berni3883 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    17
    So this might be the problem... i have 2 forms. My student form has all the students info listed in it. I combined the students last name and first name into one field using this:
    =[Last name] & ", " & [First name]

    so how would this fit into your VBA code?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  2. Command Button
    By nashr1928 in forum Forms
    Replies: 2
    Last Post: 07-05-2010, 08:02 PM
  3. Command Button
    By nashr1928 in forum Forms
    Replies: 1
    Last Post: 07-05-2010, 07:05 PM
  4. Command Button
    By lannoe in forum Forms
    Replies: 1
    Last Post: 07-01-2010, 01:48 PM
  5. Command Button Help!
    By arthura in forum Programming
    Replies: 3
    Last Post: 06-30-2009, 12:55 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