popup child field not relating back to master field

G

Guest

I have a 3 level database in this order
Region
Districts (districts within region)
Patrols
Contractors (items within each district)
Finances

The problem is that I cannot have a popup form for the 3 items. I have
regions as a form and then districts as a sub form of it. within districts I
then made 3 item subforms, used the wizard to link them to district and
region. Then I saved these forms and deleted the 3 item ones from the
picture. i then created 3 buttons which pop open the 3 item subforms which I
saved.

The problem is that I cannot get the 3 item subforms to link to the regions
of districts which are open in the other forms. so they are not connected in
any way.

If I don't use popup forms and just put them in as subforms they seem to
work, but I d not have space and need to use buttons as links.

I would appreciate any help. I have taken screen pictures of the data
structure and relationships and could send them to anyone if it would help.
E-mail me if you would like them to be sent at
(e-mail address removed)

Thank you
 
J

John Vinson

I have a 3 level database in this order
Region
Districts (districts within region)
Patrols
Contractors (items within each district)
Finances

The problem is that I cannot have a popup form for the 3 items. I have
regions as a form and then districts as a sub form of it. within districts I
then made 3 item subforms, used the wizard to link them to district and
region. Then I saved these forms and deleted the 3 item ones from the
picture. i then created 3 buttons which pop open the 3 item subforms which I
saved.

Then they are't subforms. If it's not in a Subform control it's a
completely independent stand-alone form, and will not automatically
inherit the links.
The problem is that I cannot get the 3 item subforms to link to the regions
of districts which are open in the other forms. so they are not connected in
any way.

If I don't use popup forms and just put them in as subforms they seem to
work, but I d not have space and need to use buttons as links.

One suggestion would be to use a Tab Control on the first level
subform; you could put the Patrols sub-subform on one page of the tab,
the Contractors on the second, etc.

Alternatively you can use some not terribly difficult VBA code. You'll
need to edit the VBA in the button code to set the WhereCondition and
OpenArgs arguments of the OpenForm method, to pass the ID of the
district; and then put code in the Open event of the popup form to
read the OpenArgs value and set it as the default for the DistrictID.
I would appreciate any help. I have taken screen pictures of the data
structure and relationships and could send them to anyone if it would help.
E-mail me if you would like them to be sent at

It's safest NOT to post your real email address on the newsgroups;
unfortunately, spammers love to harvest them from this (and all other)
newsgroups.


John W. Vinson[MVP]
 
G

Guest

Alternatively you can use some not terribly difficult VBA code. You'll
need to edit the VBA in the button code to set the WhereCondition and
OpenArgs arguments of the OpenForm method, to pass the ID of the
district; and then put code in the Open event of the popup form to
read the OpenArgs value and set it as the default for the DistrictID.

This sounds like something which would be most efficient. I have 3 buttons
and I don't have space for tabs. I do not have the knowledge to do this with
such little detail. Could you please reply more in depth and with any code
needed? Thanks
 
J

John Vinson

This sounds like something which would be most efficient. I have 3 buttons
and I don't have space for tabs. I do not have the knowledge to do this with
such little detail. Could you please reply more in depth and with any code
needed? Thanks

No code is needed at all.

A Tab Control is *designed* to save screen real estate. It lets you
share the same rectangular area of the computer monitor among multiple
uses. For instance, you could put a large Tab Control covering most of
the area of the form; give it four pages. Put all your current
controls on the first page;, and a subform on each of the other three.
You can choose the "button" style of tab page so that your three
buttons will... bring up the three subforms.

If you REALLY want to do it the hard way, though, you'll need code in
your buttons' click event resembling

Private Sub cmdOpenFormA_Click()
DoCmd.OpenForm "FormA", WhereCondition:="[ID] = " & [ID], _
OpenArgs:=[ID]
End Sub

and in FormA's Open event

Private Sub Form_Open(Cancel as Integer)
If Me.OpenArgs & "" <> "" Then ' was an argument passed?
Me!txtID.DefaultValue = """" & Me.OpenArgs & """"
End If
End Sub

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top