grobermatic
Technical User
Hi,
I'm using the following code to log users out of my database:
I always get Runtime Error 2046,
The Command Or Action 'Quit' isn't available now
This then prevents the database from closing. I have some code which runs at db startup which disables the application close button (top right) - I originally thought that this was the cause of the error, but having removed this completely... it still happens.
I tried putting the APPLICATION.QUIT line begind a button on a blank form and it worked fine. I therefore thought I could workaround it by making the above code open a dialog box which I could then use to execute the APPLICATION.QUIT line. However this produced the error aswell.
Any help of suggestions would be gratefully received.
Thanks in advance
Craig
--------------------------------------------------------------------------------------------------------
"Time-traveling is just too dangerous. Better that I devote myself to study the other great mystery of the universe: Women!" .. Dr E. Brown (1985)
I'm using the following code to log users out of my database:
Code:
Function LogOff(UserID As String, dteLogon As Date, dteTime As Date)
On Error GoTo err_LogOff
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim intlogID
Set db = CurrentDb
Set rst = db.OpenRecordset("tbluseagelog", dbOpenDynaset)
intlogID = DLookup("[LogID]", "tblUseagelog", "userid='" & UserID & "'" & " And logondate=#" & dteLogon & "#" & " And logofftime=null")
If IsNull(intlogID) Then Exit Function
With rst
.FindFirst "[logID] = " & intlogID
.Edit
!logofftime = Time
.Update
End With
Set db = Nothing
Set rst = Nothing
Application.Quit
'CloseAllForms "frmUserDetails"
'DoCmd.OpenForm "frmQuit", , , , , acDialog
exit_LogOff:
Exit Function
err_LogOff:
If Err.Number = 2046 Then
Else
MsgBox Err.Number & " " & Err.Description
Resume Next
End If
End Function
I always get Runtime Error 2046,
The Command Or Action 'Quit' isn't available now
This then prevents the database from closing. I have some code which runs at db startup which disables the application close button (top right) - I originally thought that this was the cause of the error, but having removed this completely... it still happens.
I tried putting the APPLICATION.QUIT line begind a button on a blank form and it worked fine. I therefore thought I could workaround it by making the above code open a dialog box which I could then use to execute the APPLICATION.QUIT line. However this produced the error aswell.
Any help of suggestions would be gratefully received.
Thanks in advance
Craig
--------------------------------------------------------------------------------------------------------
"Time-traveling is just too dangerous. Better that I devote myself to study the other great mystery of the universe: Women!" .. Dr E. Brown (1985)