Setting Recordsource when there are two or more forms open (2 Viewers)

Bobp3114

Member
Local time
Today, 19:44
Joined
Nov 11, 2020
Messages
81
I am using the following code to set the recordsource of a form depending on which form is used to open it.
If CurrentProject.AllForms("frmSalesDashboard").IsLoaded = True Then
DoCmd.OpenForm "frmActivitiesEdit", acDesign
Forms!frmActivitiesEdit.RecordSource = qryActivitiesEdit
DoCmd.Close acForm, "frmActivitiesEdit", acSaveYes
'DoCmd.OpenForm "frmActivitiesEdit", acNormal, acSaveYes
DoCmd.OpenForm "frmActivitiesEdit", , , "ActionID = " & Me.txtActionID
ElseIf CurrentProject.AllForms("frmActivitiesOverview").IsLoaded = True Then
DoCmd.OpenForm "frmActivitiesEdit", acDesign
Forms!frmActivitiesEdit.RecordSource = qryActivitiesEdit
DoCmd.Close acForm, "frmActivitiesEdit", acSaveYes
'DoCmd.OpenForm "frmActivitiesEdit", acNormal, acSaveYes
DoCmd.OpenForm "frmActivitiesEdit", , , "ActionID = " & Me.txtActionID
End If

Form SalesDashBoard is always open so the code always goes to that section of the code not to the overview section when required
Question: How do I get around this????
Thanks in advance
Bob
 
Use OpenArgs.
That is what it is there for.

Alternatively you could do it from the calling form?
Or change the order?
 

Users who are viewing this thread

  • Back
    Top Bottom