Results 1 to 3 of 3
  1. #1
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376

    Can't find the field '|1' referenced to in your expression

    Hello all,

    I have a form that I want to open to a specific record then a drop down item is chosen.

    The Code is shown below.

    Private Sub CmbConsequense_AfterUpdate()

    If CmbConsequense.Text = "Termination (Complete Termination Form)" Then

    On Error GoTo CmdTerminate_Click_Err


    ' _AXL:<?xml version="1.0" encoding="UTF-16" standalone="no"?>
    ' <UserInterfaceMacro For="CmdCloseForm" xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application"><Statements><Action Name="CloseWindow"/></Statements></UserInterfaceMacro
    ' _AXL:>
    ' Docmd.OpenForm "frmlTermination", acNormal, "", "[EmployeeID]=" [&EmployeeID], , acNormal
    DoCmd.OpenForm "frmTermination", acNormal, , "", "[EmployeeID]=", [&EmpoyeeID], acNormal

    End If


    CmdTerminate_Click_Exit:
    Exit Sub


    CmdTerminate_Click_Err:
    MsgBox Error$
    Resume CmdTerminate_Click_Exit
    End Sub
    Specifically it is the Docmd line that is the issue.

    If I put a button on the form and use the wizard to open and link it to an EmployeeID, everything work fine but I want it to work when the text in the drop down is selected. If I convert the button from a macro to vb the error occurs.

    Can someone tell me what is wrong with the Docnd line? The line below is highlited in Red and was generated when the button was converted.

    Docmd.OpenForm "frmTermination", acNormal, "", "[EmployeeID]=" [&EmployeeID], , acNormal

    Thanks

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    Could be a few things.
    You actually have a field in a table or query named &EmployeeID ? bad idea.
    You have no concatenation character to add the [&EmployeeID] field. - "[EmployeeID]=" & [&EmployeeID]
    You're using an invalid value for the window mode - acNormal is not a window mode but acWindowNormal is.

    Don't provide zls (zero length strings - "") as argument values. Just type the comma as you did for DataMode argument.

    EDIT
    If you're thinking that wrapping something in brackets [&EmployeeID] is the equivalent of Evaluate (as in Excel vba) I don't think that works in Access.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    For starters you need to concatenate the value:

    Docmd.OpenForm "frmTermination", acNormal, "", "[EmployeeID]=" & [&EmployeeID], , acNormal

    I'm wondering if the ampersand inside the brackets was meant to be outside.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Cannot find referenced Form error
    By Middlemarch in forum Programming
    Replies: 16
    Last Post: 09-18-2022, 11:52 AM
  2. Replies: 5
    Last Post: 05-04-2019, 09:02 PM
  3. VBA Unable to find referenced form
    By mdev in forum Programming
    Replies: 5
    Last Post: 03-02-2018, 10:28 AM
  4. Can't find referenced field error
    By Thompyt in forum Programming
    Replies: 7
    Last Post: 09-04-2015, 09:00 AM
  5. Replies: 1
    Last Post: 03-05-2014, 07:55 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