Running a form with different openargs twice

atrium

Registered User.
Local time
Tomorrow, 02:19
Joined
May 13, 2014
Messages
348
SQL:
If OpIdFld = 10 Then    ' For Luke - Check

         Me.ABABranchIdFld = 1

         DoCmd.OpenForm "DdCreateABAFileMonitorFrm", acNormal, , , , , Me.ABABranchIdFld



         Me.ABABranchIdFld = 2

         DoCmd.OpenForm "DdCreateABAFileMonitorFrm", acNormal, , , , , Me.ABABranchIdFld

      End If

If I run it as it is I only get the second report. If I put any sort of delay between the first and second I only get the first. I need both forms displayed.

Can anyone help me
 
Last edited by a moderator:
If I run it as it is I only get the second report. If I put any sort of delay between the first and second I only get the first. I need both forms displayed.

Do you mean Form NOT Report?

If so, Are the Forms Modal?
 
Forms sorry, yes the form is modal
 
If a form or report is already open, simply attempting to open it will only activate it again. You would have to close and reopen, or create a form property and alter that property value in the first form's code.
Not sure, but the OpenArgs property may be editable from the first form. I've only seen code that alters a custom property.
 
As already stated, OpenArgs only works when a form is first opened and has no effect on a currently open form.
You could try doing this is the filter criteria argument instead or have 2.identical forms and open each in turn.
However duplicating objects is generally a bad idea.
 
I need both forms displayed.
Hi. Sounds like you want to open multiple instances of the same form. If so, take a look at Allen Browne's website to see how. Good luck.
 
Last edited:
Yes you can open multiple instances of same form. Here is an example. The Allen Browne stuff explains it well. The code is something like this
Code:
Option Explicit
'need a module level variabe
Private frm1 As Form_frmInstance
Private frm2 As Form_frmInstance
Private Sub Command1_Click()
  'Instantiate
  Set frm1 = New Form_frmInstance
  Set frm2 = New Form_frmInstance
  'set properties
  With frm1
    .Caption = "David Cressy"
    .Detail.BackColor = vbRed
    .Lbl1.Caption = "David Cressy"
    .Filter = "[First Name] = 'David Cressy'"
    .FilterOn = True
  End With
  With frm2
    .Caption = "Moses Rotz"
    .Detail.BackColor = vbGreen
    .Lbl1.Caption = "Moses Rotz"
    .Filter = "[First Name] = 'Moses Rotz'"
    .FilterOn = True
  End With
  frm2.Move 4 * 1400
  'Must make visible
  frm1.Visible = True
  frm2.Visible = True
End Sub
 

Attachments

Here is another example that loads multiple instances of the Form with different information in memory and displays two of them on the Screen at the same time:
Code:
Public Function frmInstanceTest()

'Create first instance of the form frmEmployees
'and opens it in memory(not visible in application window)
      Dim frm As New Form_frmEmployees

'Create second instance of the Form frmEmployees
'and opens it in memory(not visible in application window)
      Dim frm2 As New Form_frmEmployees

'Name1, Name2 string variables
      Dim Name1 As String, Name2 As String

'Make both instances of the frmEmployees
'visible in the Application Window

  frm.Visible = True
  frm2.Visible = True

'Call the GetFirstName() Public Function of
'1st instance of the frmEmployees with Employee ID: 4
'Record of ID 4 becomes current on frmEmployees
'and returns first name to variable Name1

  Name1 = frm.GetFirstName(4)
  
'Call the GetFirstName() Public Function of
'2nd instance of the frmEmployees with Employee ID:5
'Record ID 5 becomes current on frmEmployees
'and returns first name to the variable Name2

  Name2 = frm2.GetFirstName(5)

'pause execution of this code to view
'the Employees Form instances in Application Window.

Stop

'display the first names retrieved from
'both instances of the Employees Form
  MsgBox "Employees " & Name1 & ", " & Name2
End Function

Find more details here: https://www.msaccesstips.com/2016/08/opening-multiple-instances-of-form-in.html
 
Last edited:
thank you everyone for your input. I was a bit strapped for time so I made 2 different reports to overcome any problems

Thanks Again:)

Atrium
 
thank you everyone for your input. I was a bit strapped for time so I made 2 different reports to overcome any problems

Thanks Again:)

Atrium
Hi. Glad to hear you found a solution that works for you. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom