Darren Bartrup
Well-known Member
- Joined
- Mar 13, 2006
- Messages
- 1,297
- Office Version
- 365
- Platform
- Windows
I have a form (frmSwitchboard) which opens another form (frmProcessReturns) when a command button is pressed (the first form is hidden rather than unloaded at this point).
When I close the second form and press the button to reopen it I get an run-time error message 400: 'Form already displayed; can't show modally'.
Sure enough, if I move the the first form out of the way the second form is still sitting there behind it. I can't activate it, but I presume this is because the first form is modal.
Here's the code that's relevant to the forms:
In a module:
In frmSwitchboard form:
In frmProcessReturns form:
I'm guess that it's something to do with the last section of code, but I thought if I press the 'x' to close the form it would close it.
I've tried it with Screenupdating on & off and calculation on and off but it still gives the same error.
Any ideas???
Thankyou for any input!
When I close the second form and press the button to reopen it I get an run-time error message 400: 'Form already displayed; can't show modally'.
Sure enough, if I move the the first form out of the way the second form is still sitting there behind it. I can't activate it, but I presume this is because the first form is modal.
Here's the code that's relevant to the forms:
Code:
Option Explicit
Private Sub Workbook_Open()
OpenForm
End Sub
Code:
Option Explicit
Public Sub OpenForm()
Dim strSQL As String
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
strSQL = "SELECT [tblTeamManagement].[fldTeamName], " & _
"[tblTeamManagement].[fldIgnore], " & _
"[tblTeamManagement].[fldToContact], " & _
"[tblTeamManagement].[fldCCContact], " & _
"[tblTeamManagement].[fldReContact] " & _
"FROM [tblTeamManagement];"
Load frmImportGAL
frmImportGAL.Show
InitialiseGlobalVariables
Load frmSwitchboard <<<<< LOAD THE FIRST FORM.
PopulateTeamNames frmSwitchboard.fraTeams, strSQL
DisplayEmailText
Application.Calculation = xlCalculationAutomatic
frmSwitchboard.Show <<<<< SHOW THE FIRST FORM.
Application.ScreenUpdating = True
End Sub
Code:
Private Sub cmdProcess_Click()
Load frmProcessReturns <<<<<< LOAD THE SECOND FORM.
frmProcessReturns.Show <<<<<< SHOW THE SECOND FORM.
End Sub
Code:
Private Sub UserForm_Initialize()
Dim rsServiceType As New ADODB.Recordset
frmSwitchboard.Hide <<<<< HIDE THE FIRST FORM.
With rsServiceType
.Open "SELECT tblServiceType.fldServiceType " & _
"FROM tblServiceType;", GV.cn, adOpenKeyset, adLockReadOnly, adCmdText
.MoveFirst
Do While Not .EOF
Me.lstServiceType.AddItem .Fields(0)
.MoveNext
Loop
.Close
End With
GatherWorkBookNames
Me.Tag = 1
LoadWorkBookToForm Me.Tag
End Sub
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Workbooks(Me.Caption).Close False
frmSwitchboard.Show <<<<< SHOW THE FIRST FORM AGAIN.
End Sub
I've tried it with Screenupdating on & off and calculation on and off but it still gives the same error.
Any ideas???
Thankyou for any input!