Forms/SubForms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I have used a sub form within a form, I have usually used a query or
table and that has enabled me to bound objects together, this time I am using
a table or query from another database. All my objects are now unbound and
from the Open_Form() I load in the query or table using SQL.
How is it possible to use the linking of Master & Child fields?
 
You cannot use LinkMasterFields/LinkChildFields on an unbound form.

You could link the tables (File | Get External), and use bound forms.
 
Allen,

I am using an ADO Connection between the database, so that on Load_Form() it
connects to my back end DB, and brings in the query/table. So if unbound
objects cant be linked, how can I link the sub form to the main form?
 
I am using an ADO Connection between the database, so that on Load_Form() it
connects to my back end DB, and brings in the query/table. So if unbound
objects cant be linked, how can I link the sub form to the main form?
 
Every time you change record in the main form, Access loads the approriate
records into the subform (based on LinkMasterFields/LinkChildFields.)

If your forms are unbound, you cannot use this functionality to load
records.

I don't know how to be any clearer than that.
 
So if unbound
objects cant be linked, how can I link the sub form to the main form?

If you are working with an truly unbound form, then you need to write code
(the Parent's Form_Current event, most likely) to replicate the
synchronization that the Master/Child link properties would handle
automatically for bound forms.

In other words, you gotta do it yourself...

Alternatively, maybe you can set Master/Child link properties in code after
your query/table has been loaded in Form_Load? (It sounds like it really is
a bound form, but it's just not being bound until runtime, so you can't set
Master/Child properties until then either...)

HTH,
 
George,

Ok, so on writing code to the Form_Current() on the main form, am I writing
something like this to pull the records through on the subform?

Dim intCSATNumber As Integer
Dim sQRY As String

intCSATNumber = Me.CSATNumber 'from the main form.

sQRY = "SELECT * FROM tblMySubFormTable WHERE CSATNumber = " & intCSATNumber
 
....and then assign sQRY to the subform's recordsource? Yes.

Another approach would be to assign the recordsource once at Startup and
then reset the subform's filter on the fly.

HTH,
 
Back
Top