Share via

Compile Error: Variable not defined

Anonymous
2011-09-18T07:48:17+00:00

Hi.

I have the following code that works.  I added the line DoCmd.OpenQuery(UpdateCurrentUser)  which is an update query, but I keep getting a compile error: Variable not defined.

' ***********************************************************

'   User has entered user_id and Password

' ***********************************************************

Private Sub cmdOK_Click()

On Error GoTo Err_cmdOK_Click

    DoCmd.OpenQuery (UpdateCurrentUser)

    ' Validate User ID and Password and then display menu items

      display_menu

Exit_cmdOK_Click:

    Exit Sub

Err_cmdOK_Click:

    MsgBox Err.Description

    Resume Exit_cmdOK_Click

End Sub

Does anyone know what I need to do to stop this?

Thanks

AJ

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-09-18T08:50:17+00:00

The name of the query must be in quotes.

It's unlikely that you really want to open the query's datasheet, but you didn't say why you want to do that.  More likely, you only need to use the DLookup function to check the user id and password.  OTOH, if the query is an action query, it would be better to use the Execute method.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful