Sytax Error (missing operator) in expression

Chimp8471

Registered User.
Local time
Today, 13:13
Joined
Mar 18, 2003
Messages
353
i keep getting that above message when i click on my exit database button, which i hach put on one of my forms.

the code behind that button is as follows, would appreciate it if you could see anything obvious that would cause this error.

Option Compare Database
Option Explicit
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim intResponse As Integer
Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = currentdb()
Set rst = db.OpenRecordset("ztblUserLog", dbOpenDynaset)

Forms!fmnuMainMenu.Visible = False

intResponse = MsgBox("Warning: You are about to completely exit the database." & Chr(13) & _
"Are you sure you want to do this?", vbYesNo + vbExclamation, "Exiting Database")

Select Case intResponse
Case vbYes
rst.FindLast "SecurityID = " & User.SecurityID
rst.Edit
rst!TimeOut = Now()
rst.Update
DoCmd.Quit

Case Else
Forms!fmnuMainMenu.Visible = True
End Select

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

Cheers

Andy
 
Might be helpful if you highlight which line the error occurs on...


Comment the On Error Goto line out first.
 
it appears to happen as this line is highlighted,

Resume Exit_Command3_Click

this is the last line before the bottom end sub

hope this is what you meant

cheers

Andy
 
Change your code to this:

Code:
Private Sub Command3_Click() 

    On Error GoTo Err_Command3_Click 

    Dim db As DAO.Database 
    Dim rst As DAO.Recordset 

    Set db = CurrentDb
    Set rst = db.OpenRecordset("ztblUserLog", dbOpenDynaset) 

    Forms!fmnuMainMenu.Visible = False 
  
    If MsgBox("Warning: You are about to completely exit the database." & Chr(13) & _ 
    "Are you sure you want to do this?", vbYesNo + vbExclamation, "Exiting Database")  = vbYes Then
        rst.FindLast "SecurityID = " & User.SecurityID 
        rst.Edit 
        rst!TimeOut = Now() 
        rst.Update 
        DoCmd.Quit 
    Else 
        Forms!fmnuMainMenu.Visible = True 
    End If

Exit_Command3_Click:
    rst.Close
    db.Close
    Exit Sub 

Err_Command3_Click: 
    MsgBox Err.Description 
    Resume Exit_Command3_Click 

End Sub


I suspect it's actually your SELECT CASE statement where you are saying "Case vbYes" when what you really want is "Case Is = vbYes"

I just thought I'd remove the need for the SELECT CASE altogether, anyway.
 

Users who are viewing this thread

Back
Top Bottom