Results 1 to 8 of 8
  1. #1
    Jgk is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    46

    Form Event Procedure

    Form =frmMenu


    Field of Form = txtuser
    filter to go to record on load event
    Form = frmContractor
    Find Record or Field = Login

    I am trying to get it to go to find a specific record on form

    Here is the on load Event Procedure I get syntax error
    Private Sub Form_Load()
    Open the form
    DoCmd.OpenForm "frmContractor", acNormal, , sWHERE Login = Environ("username")
    End Sub

    Thanks

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    DoCmd.OpenForm "frmContractor", acNormal, , sWHERE Login = Environ("username")
    What is "Login" and what is "sWHERE"
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Jgk is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    46
    login = username on frmMenu and is on frmContractor
    swhere I was trying that I found on this forum. Really not sure why it is not just where login = Environ("username")

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    What happens with just WHERE
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Jgk is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    46
    compile error expected:end of statement error syntax error

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Perhaps something like:
    DoCmd.OpenForm "frmContractor", acNormal, , "Login = '" & Environ("username") & "'"
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    Jgk is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    46
    Thank you it works

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Bob's suggestion is valid syntax.

    sWHERE was probably a variable that was populated by code in whatever example you were following. Also demonstrated in http://allenbrowne.com/ser-62code.html which you might find useful for more complex filtering requirements.
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 03-29-2014, 07:46 PM
  2. Replies: 5
    Last Post: 08-22-2012, 07:32 AM
  3. Replies: 3
    Last Post: 05-07-2012, 12:17 PM
  4. 'After update' Event procedure
    By sk88 in forum Access
    Replies: 5
    Last Post: 08-30-2011, 02:51 PM
  5. On-Click Event Procedure
    By tbassngal in forum Forms
    Replies: 6
    Last Post: 07-20-2011, 07:06 AM

Tags for this Thread

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