loop form

E

Edo

I have a FE/BE-db with the possibility to block the db for maintenance. After
the startform a hidden form will be opened which checks the table settings
for a value. If the value is yes, then the db will be closed and locked. If
it is no, then the mainform will open.

I just found out this is not working properly. The shutting down and
blocking of the db is no problem. But opening the mainform is in a loop. The
form opens directly after shutting down the form.

I checked where the problem lies by opening the db in designmode and then
open the mainform, it causes no problem. But when I open the hidden form the
main is in a loop again.

The code below I found in a sample db which I found in the internet. I just
added the line: >else >DoCmd.OpenForm "frmStoringen" to open the mainform if
the db isn’t blocked. Somewhere I’v done something wrong. Who can help me out?

Private Sub Form_Load()
Dim db As DAO.Database
Dim snp As DAO.Recordset
Dim msg As String

Set db = CurrentDb
Set snp = db.OpenRecordset("Settings", dbOpenSnapshot)
If snp![logoff] Then
msg = "De database is tijdelijk gesloten voor onderhoud!" & vbCrLf & vbCrLf
& "Probeer later nog eens."
MsgBox msg
Application.Quit
End If
DoCmd.Hourglass False

End Sub


Private Sub Form_Timer()
Dim db As DAO.Database
Dim snp As DAO.Recordset
Dim msg As String, intLogoff As Integer

Set db = CurrentDb
Set snp = db.OpenRecordset("Settings", dbOpenSnapshot)
intLogoff = snp![logoff]
snp.Close
db.Close

If intLogoff = True Then
Me.TimerInterval = 300000
If Me.Tag = "MsgSent" Then
Application.Quit (acQuitSaveAll)
Else
Me.Tag = "MsgSent"
DoCmd.OpenForm "frm_ExitNow"
End If
Else
DoCmd.OpenForm "frmStoringen"
End If

End Sub
 
M

Marshall Barton

Edo said:
I have a FE/BE-db with the possibility to block the db for maintenance. After
the startform a hidden form will be opened which checks the table settings
for a value. If the value is yes, then the db will be closed and locked. If
it is no, then the mainform will open.

I just found out this is not working properly. The shutting down and
blocking of the db is no problem. But opening the mainform is in a loop. The
form opens directly after shutting down the form.
[snip]


I could swear that I answered this in another newsgroup.

Please don't post the same question multiple times.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Timer event not working. 4
LogUsersOff 0
LogUsersOff 0
Match style 0
AddPicturesToShapes 0
VBA Export to PDF 0
Remove Identical words 0
Working outlook via vba code with xlsx - error 0

Top