Subform selection should open form with two subforms (1 Viewer)

silentwolf

Active member
Local time
Yesterday, 20:51
Joined
Jun 12, 2009
Messages
575
Stuck again,

sorry for posting that many questions but need to get some things done and getting stuck.

What I am trying to do is open a form from a subform selection in another form.
Problem is that the form I like to open has two subforms and a textbox in the header.

Attached the pic of the second form I like to open.

Code in the first form

Code:
    DoCmd.OpenForm "frmCustomerTab", datamode:=acFormEdit, _
        WindowMode:=acWindowNormal, WhereCondition:=CustomerID = " & Me!sfmAllCustomers!CustomerID"

The second forms name is frmCustomerTab

the code above is what I am trying but not sure what control I need to refer to to make it work.

Could someone tell me please?

Many thanks
 

Attachments

  • Subform.JPG
    Subform.JPG
    136 KB · Views: 72

XPS35

Active member
Local time
Today, 05:51
Joined
Jul 19, 2022
Messages
160
I don't think the fact that the form you want to open has subforms is a problem.
The way you open it is more likely a problem. Where did you place the button to open the second form? If it is on the first mainform, your code won't work. On the subform there can be multiple CustomerIDs so referring to Me!sfmAllCustomers!CustomerIDs is not logical.
Make a button on the detail section of the first subform and refer to Me.CustomerID.
 

silentwolf

Active member
Local time
Yesterday, 20:51
Joined
Jun 12, 2009
Messages
575
Hi,

thanks for your reply!
Where did you place the button to open the second form?
The button in on frmCustomerSearch Header.
on that form I have a subform sfmAllCustomers.

and when I select a Customer in that subform I like to open another form with that particular CustomerID

I can open another form with that kind of code when I open a form where the CustomerID is in the detail section of that form.


What I have tried was
Code:
Where:="frmCustomerTab!sfmCustomerSearchMini.Form!CustomerID = " & Me!sfmAllCustomers!CustomerID

but it only opens the frmCustomerTab ok but just without any filter.

Would love to keep it as the forms a designed if possiple.
So it would not be possible at all to do that?
 

XPS35

Active member
Local time
Today, 05:51
Joined
Jul 19, 2022
Messages
160
Would love to keep it as the forms a designed if possiple.
So it would not be possible at all to do that?
As I explained you need to change the design. Then it is possible.
 

Gasman

Enthusiastic Amateur
Local time
Today, 04:51
Joined
Sep 21, 2011
Messages
14,400
You do not refer to a form control on the left hand side of the where, but the source field of that form.
 

silentwolf

Active member
Local time
Yesterday, 20:51
Joined
Jun 12, 2009
Messages
575
Unfortunatelly I can not get it to work.

Tried different things but without look.

It would need to be the same as if you would open the frmCustomerTab with the record selected in the sfmCustomerSearchMini

sfmCustomerSearchMini is based on a query, qryCustomerSearch where I have a control CustomerID

with that selection I put the ID into txtCustomerID
to filter sfmCustomerHead

So sfmCustomerHead is displaying the CustomerHeader so to speak . and on the datasheet I can look for a Customer

Or should I do that differently?
Maybe there is a simpler or better way of achieving this.


On the subform there can be multiple CustomerIDs so referring to Me!sfmAllCustomers!CustomerIDs is not logical.
Make a button on the detail section of the first subform and refer to Me.CustomerID.

Unfortunatelly I am not exactly sure what you mean how to refer to in the whole content?

First I select the Record in the "first Subform sfmAllCustomers after I do select it I click it and would like to get to the selected Customer in frmCustomerTab

I am able to open different forms but there is the Datasource in the 2 form in the details section and there the field CustomerID

Thanks
 

Users who are viewing this thread

Top Bottom