Results 1 to 4 of 4
  1. #1
    Mtyetti2 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    26

    DoCmd.GoToRecord

    I have an employee database which has a login form. A query returns the value of the last employee logged in. I use this to restrict edits/features on various form 'onopen'.


    I have a basic Employee Form. I'd like to that form to only open to the record of the current employee who is logged in. In other words, open the form and go to the record where the LogIn employee value matches the Employee ID.

    I'm looking for the docmd.gotorecord code, not a macro.

    Thanks for the help!

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    You probably want to use DoCmd.OpenForm. With this, you can apply a where condition to the open event that will affect the recordsource of the form vs. only navigation to a record within a recordset.

    DoCmd.OpenForm "frmMyForm", , , "[EmployeeID]= glngEmployeeID"

    Here, this code assumes that there is a global variable that holds the value of the EmployeeID.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Except do not include the variable within quotes, concatenate variables.

    DoCmd.OpenForm "frmMyForm", , , "[EmployeeID]=" & glngEmployeeID
    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.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Thanks for catching that June

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

Similar Threads

  1. Replies: 10
    Last Post: 03-12-2013, 01:41 PM
  2. Replies: 19
    Last Post: 12-02-2012, 07:01 PM
  3. Replies: 1
    Last Post: 10-01-2010, 04:44 AM
  4. GoToRecord Help
    By rayhawk in forum Access
    Replies: 10
    Last Post: 08-30-2010, 12:44 PM
  5. GoToRecord Help!!!!!!
    By Kipster1203 in forum Access
    Replies: 8
    Last Post: 06-11-2010, 11:12 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