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

    Access On Click event not working on form


    Access On Click event not working on form. Access cannot find the field '1' referred in your expression


    Private Sub btnPreview_Click()
    DoCmd.SetWarnings False
    cboFullName.SetFocus
    DoCmd.OpenQuery ([Open Projects Employee])
    DoCmd.OpenForm ("[Open Projects].[Owner]"), acViewPreview
    DoCmd.SetWarnings True
    End Sub

    Private Sub cboEmployeeName_Click()
    Dim myName As String
    myName = "Select * from Projects where ([Owner]=" & Me.cboEmployeeName & ")"
    Me.[Project List].Form.RecordSource = myName
    Me.[Project List].Form.Requery
    End Sub

  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,521
    Which one? If I had to guess:

    myName = "Select * from Projects where [Owner]=" & Chr(34) & Me.cboEmployeeName & Chr(34)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Welcome the the forum....


    Not a lot of info to go on.....

    Which click event has the error?


    Looking at the btnPreview code, I see two errors immediately.
    1)
    Code:
    DoCmd.OpenQuery ([Open Projects Employee])
    This is improper syntax. The query name should be a string.
    Example:
    Code:
    DoCmd.OpenQuery "OpenProjectsEmployee"
    Also, you should not use spaces in object names.... (I removed them in the example)

    2)
    The second error is
    Code:
    DoCmd.OpenForm ("[Open Projects].[Owner]"), acViewPreview
    I doubt that you have a form named "[Open Projects].[Owner]".
    Again, the form name should be a string, like the form names in the Navigation Pane.

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

Similar Threads

  1. Right click event - move button not working ?
    By Lukael in forum Programming
    Replies: 2
    Last Post: 02-08-2016, 11:48 AM
  2. Replies: 13
    Last Post: 09-10-2015, 03:37 PM
  3. Click event of form?
    By BLFOSTER in forum Programming
    Replies: 3
    Last Post: 04-25-2014, 11:29 AM
  4. Replies: 6
    Last Post: 05-12-2013, 01:52 PM
  5. On Click Event For Button On Form
    By Desstro in forum Forms
    Replies: 3
    Last Post: 08-09-2010, 02:36 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