I would start by compiling the code, if you haven't already. After that I
would comment out that code and see what happens. It looks to me that the
loop run before the If statement begins. Assuming the loop works as
intended, why not just put it in the Else part of the If statement?
Else
Wait = 120
Start = Timer
Do While Timer < Wait + Start
DoEvents
Loop
Without knowing what rst!Time is, it is difficult to evaluate that loop, but
Time is a reserved word, which could cause problems unless it is in square
brackets (assuming it is a field).
If commenting out the code lets you open both forms, and if the suggestion
about moving the loop to Else makes sense, the next step may be to set a
break point at the start of each loop, and at the end of the last one, and
step through the code to identify the place where things go wrong.
Here are some links to code for kicking users off of the system:
http://www.accessmvp.com/JConrad/accessjunkie/kickoff.html
If you don't have a split database you should consider doing so.
http://allenbrowne.com/ser-01.html
wow, lots of questions. Ok,
Ossie: frmOFFLINE queries a table called tblMAINT every two minutes
to check for "Maintenance Mode". If tblMAINT.OFFLINE = 1 then the
form unhides and displays a message asking all users to please exit
the system as it will be down for maintenance at such-n-such a time.
The reason the form opens hidden is because the user dosn't need to
see the form unless the system will be down for maintenance. The only
problem I have is that if the user has the computer locked the code
does not run and they will remain in the system. Since we do not
utilize logins there is no way for me to programmatically boot them
out of the system.
Bruce and John: It appears that frmOFFLINE opens first and then
frmMain opens after the second click. The idea was to have the user
click the "Accept" button only once and have both forms open.
The only code in the form is a command button to close the db and:
Private Sub Form_Current()
Dim Start, Wait
Dim rst As DAO.Recordset
Loops:
Wait = 120
Start = Timer
Do While Timer < Wait + Start
DoEvents
Loop
Set rst = CurrentDb.OpenRecordset("tblMaint")
If rst!Offline = 1 Then
With Forms(Me.NAME)
.Modal = True
.Visible = True
End With
Do While Now() < rst!Time
DoEvents
Loop
DoCmd.Quit
Else
GoTo Loops
End If
End Sub
frmOFFLINE is a pop-up but it is not modal, until it displays itself,
then it is a modal pop-up form. The only thing I still need to add to
the above code is to tell it to save all records before it closes.- Hide quoted text -
- Show quoted text -