R
Rob
Hi all,
I am having some trouble opening multiple instances of forms. I use the
following code to open a form. I am using the NewTaskForm (which is taken
directly from the Access Developers Handbook 97), to create new instances
of forms. I use the same form in different ways (add, veiw, edit) and each
view has different properties (although not significant). The problem is
that when I open the second instance, I am presented with the input box
from my Form_Load event. Does this have something do do with the scope of
the iTaskType variable (the iTaskType variable is declared as a Public
variable in frmTasks)?
Here is the code that opens a new form:
If IsOpen("frmTasks") Then
Call NewTaskForm(cNewTask)
Else
DoCmd.OpenForm "frmTasks", acNormal, , , , acWindowNormal, cNewTask
End If
And the NewTaskForm procedure (from the ADH97 book):
Sub NewTaskForm(iFrmType As Integer)
Dim frm As Form
Set frm = New Form_frmTasks
With frm
.iTaskType = iFrmType
End With
mintI = mintI + 1
colForms.Add Item:=frm, KEY:=frm.hwnd & ""
DoCmd.MoveSize (mintI + 1) * 80, (mintI + 1) * 350
frm.Visible = True
End Sub
And then in the Form_Load event of "frmTasks" I have the following code:
' Allow design of the form
If IsNull(Me.OpenArgs) Then
If iTaskType = 0 Then ' Uninitialised
iTaskType = CInt(InputBox("Enter a form type"))
End If
Else
iTaskType = Me.OpenArgs
End If
Select Case iTaskType
Case cNewTask
Case cViewTask
Case cEditTask etc ...
I have also tried using the iTaskType as a global variable and changing it
before each NewTaskForm call, but I still get the same error.
Any help anybody could provide would be greatly appreciated,
Cheers
Rob
I am having some trouble opening multiple instances of forms. I use the
following code to open a form. I am using the NewTaskForm (which is taken
directly from the Access Developers Handbook 97), to create new instances
of forms. I use the same form in different ways (add, veiw, edit) and each
view has different properties (although not significant). The problem is
that when I open the second instance, I am presented with the input box
from my Form_Load event. Does this have something do do with the scope of
the iTaskType variable (the iTaskType variable is declared as a Public
variable in frmTasks)?
Here is the code that opens a new form:
If IsOpen("frmTasks") Then
Call NewTaskForm(cNewTask)
Else
DoCmd.OpenForm "frmTasks", acNormal, , , , acWindowNormal, cNewTask
End If
And the NewTaskForm procedure (from the ADH97 book):
Sub NewTaskForm(iFrmType As Integer)
Dim frm As Form
Set frm = New Form_frmTasks
With frm
.iTaskType = iFrmType
End With
mintI = mintI + 1
colForms.Add Item:=frm, KEY:=frm.hwnd & ""
DoCmd.MoveSize (mintI + 1) * 80, (mintI + 1) * 350
frm.Visible = True
End Sub
And then in the Form_Load event of "frmTasks" I have the following code:
' Allow design of the form
If IsNull(Me.OpenArgs) Then
If iTaskType = 0 Then ' Uninitialised
iTaskType = CInt(InputBox("Enter a form type"))
End If
Else
iTaskType = Me.OpenArgs
End If
Select Case iTaskType
Case cNewTask
Case cViewTask
Case cEditTask etc ...
I have also tried using the iTaskType as a global variable and changing it
before each NewTaskForm call, but I still get the same error.
Any help anybody could provide would be greatly appreciated,
Cheers
Rob