Results 1 to 12 of 12
  1. #1
    akrylik is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    47

    Going from one Form to another based on field


    I have two forms, Employee Data Input(has employee information on it) Form and a Resource Allocation Form(employee's current project) that I am using to track individuals and their projects. I am trying to create a button to go from the Resource Allocation Form to the Employee Data Input Form based on the Last Name in the Resource Allocation Form. Would docmd.OpenForm be the best way to go? If so, how would i code the parameters to apply that filter?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    See if this helps:

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

  3. #3
    akrylik is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    47
    its asking me to enter parameter value. Im trying to get the automated so it doesnt pop up but goes to the correct record.

  4. #4
    akrylik is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    47
    This is the code im using :

    DoCmd.OpenForm "EmployeeDataInputForm", , , "Last_Name = '" & Me.Last_Name & "'"

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    If you're getting a parameter prompt, one of those is spelled wrong or the field isn't in the second form's source. Is there a space in the field name rather than the underscore?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    akrylik is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    47
    Yes there is a space in the name of the button. Should it be me.[last name]?

  7. #7
    akrylik is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    47
    When I run it with the following code i get the following error message:

    DoCmd.OpenForm "EmployeeDataInputForm", , , "Last Name = '" & Me.[Last Name] & "'"

    run-time error '3075':
    Syntax error (missing operator) in query expression 'Last Name = 'Adams".

    where Adams is the last name in Form 1 and i want to view info on Adams in Form 2

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    You need the field name brackted too:

    DoCmd.OpenForm "EmployeeDataInputForm", , , "[Last Name] = '" & Me.[Last Name] & "'"

    See why we recommend against spaces?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    akrylik is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    47
    IT WORKS! Thanks man.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    akrylik is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    47
    Another question, Say i have a submit button and i want to add the same person's name to a new record. I want to hit submit, go to a new form and auto fill the LastName field with the same last name on the previous record. Should i create a temp. variable that holds the value of the last name field and then use that variable to fill the field in the new record?

  12. #12
    akrylik is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    47
    Nevermind, i figured it out. Thanks

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

Similar Threads

  1. Replies: 3
    Last Post: 10-03-2011, 02:33 PM
  2. Replies: 2
    Last Post: 07-14-2011, 09:23 AM
  3. Find records based on a field in a form
    By rbw95662 in forum Programming
    Replies: 3
    Last Post: 06-15-2010, 04:12 PM
  4. Autofill form fields based on another field
    By ljs1277 in forum Access
    Replies: 3
    Last Post: 02-16-2010, 02:51 PM
  5. Replies: 1
    Last Post: 11-10-2009, 03:20 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