Reload a Form

Learn2010

Registered User.
Local time
Today, 06:32
Joined
Sep 15, 2010
Messages
415
We are on a large network. I have users that work in remote locations. When using the database, a fresh login removes all the data in the tables behind the forms they are filling in. Occasionally, the connection is lost. The fresh login was the only thing they could do. Now, I have figured out a way for them to reopen the database and return to the forms they were using, with all the data intact.

I use a Select Case statement to do this. In the following example when I had Case "X" and Case "P" it worked well. I added another Case, Case "CLEntry" to the procedure. When the form opens that I am using this code behind, it says "Compile Error: Case without Select Case." Here is the code.

START OF CODE

Private Sub Form_Load()
Select Case LastLocation
Case "X"
DoCmd.Close acForm, "frmLoad"
OpenMain
Case "P"
Dim RResponse As Integer
RResponse = MsgBox("The database seems to have closed unexpectedly. Do you wish to return to the form you were working on?", vbYesNo, "Continue")
If RResponse = vbYes Then
DoCmd.Close acForm, "frmLoad"
DoCmd.OpenForm "frmMain"
Forms!frmMain.LastLocation = "X"
Forms!frmMain!frmMainSub.SourceObject = "frmMainReload"
DoCmd.Maximize
Else
Cancel = True
DoCmd.Close acForm, "frmLoad"
OpenMain
Case "CLEntry"
Dim RResponse As Integer
RResponse = MsgBox("The database seems to have closed unexpectedly. Do you wish to return to the form you were working on?", vbYesNo, "Continue")
If RResponse = vbYes Then
DoCmd.Close acForm, "frmLoad"
DoCmd.OpenForm "frmMain"
Forms!frmMain.LastLocation = "X"
Forms!frmMain.frmMainSub.SourceObject = "frmMainSubContactLogEntries"
DoCmd.Maximize
Else
Cancel = True
DoCmd.Close acForm, "frmLoad"
OpenMain
End If
End Select
End Sub

END OF CODE

Can you tell me why and what I need to do?
 
Quite hard to read without it being in code tags and indented.
Looks like you have missed an endif for the first if statement?, going by the second if statement.

We are on a large network. I have users that work in remote locations. When using the database, a fresh login removes all the data in the tables behind the forms they are filling in. Occasionally, the connection is lost. The fresh login was the only thing they could do. Now, I have figured out a way for them to reopen the database and return to the forms they were using, with all the data intact.

I use a Select Case statement to do this. In the following example when I had Case "X" and Case "P" it worked well. I added another Case, Case "CLEntry" to the procedure. When the form opens that I am using this code behind, it says "Compile Error: Case without Select Case." Here is the code.

START OF CODE

Private Sub Form_Load()
Select Case LastLocation
Case "X"
DoCmd.Close acForm, "frmLoad"
OpenMain
Case "P"
Dim RResponse As Integer
RResponse = MsgBox("The database seems to have closed unexpectedly. Do you wish to return to the form you were working on?", vbYesNo, "Continue")
If RResponse = vbYes Then
DoCmd.Close acForm, "frmLoad"
DoCmd.OpenForm "frmMain"
Forms!frmMain.LastLocation = "X"
Forms!frmMain!frmMainSub.SourceObject = "frmMainReload"
DoCmd.Maximize
Else
Cancel = True
DoCmd.Close acForm, "frmLoad"
OpenMain
Case "CLEntry"
Dim RResponse As Integer
RResponse = MsgBox("The database seems to have closed unexpectedly. Do you wish to return to the form you were working on?", vbYesNo, "Continue")
If RResponse = vbYes Then
DoCmd.Close acForm, "frmLoad"
DoCmd.OpenForm "frmMain"
Forms!frmMain.LastLocation = "X"
Forms!frmMain.frmMainSub.SourceObject = "frmMainSubContactLogEntries"
DoCmd.Maximize
Else
Cancel = True
DoCmd.Close acForm, "frmLoad"
OpenMain
End If
End Select
End Sub

END OF CODE

Can you tell me why and what I need to do?
 
The End If was missing. Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom