synchronizing forms on unbound form

G

Guest

This isn't my favorite way to set up forms but I"m dealing with shared data
and don't have a lot of choice in the design.

I have two tables Task table and Task Details table in a one to many
relationship because depending on the task there could be a lot of notes.

I have an unbound form and two bound forms on the unbound form. Form1 is
the unbound form. Form 2 is a bound form dragged onto form one and bound to
the task table. Form 3 is a bounc form bound to the task details table and
dragged onto Form 1.

the problem is that because they're two bound forms on an unbound form I
don't get link child and link master fields to work so the notes aren't
following along per task.

I've tried several things to get the forms to synchronize with each other
but I need Form 1 in data sheet view and Form 2 in form view so I can't
really combine everything into one query as far as I can tell. I tried on
current events of Form 1 and Form 2 but it doesn't seem to requery Form 3
well.

Thoughts or suggested links?
 
G

Guest

You can still use the link child and link master fields in an unbound form.
First set the fields up like you would if your unbound form was bound.
Then in the on current event of your master form set the sub form's
recordsource = a ADO record source like this:


''''''''''''''''''''''''''''''''''''''
Dim rs As ADODB.Recordset
Dim sSQL As String
Dim cnn As ADODB.Connection
Dim x As Boolean

Set cnn = New ADODB.Connection
'cnn is not needed in my example because i used CurrentProject.Connection.
'If you need to connect to another database then you set the data source
giving it a path
'cnn.Open "Provider= Microsoft.Jet.OLEDB.4.0; Data Source= C:\Test\db1.mdb ;"
'You might want to read up on ADO.

Set rs = New ADODB.Recordset

sSQL = "SELECT * FROM tblEmpHist "
rs.Open sSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic

frmEmpHist_sub.Form.RecordSource = rs.Source
''''''''''''''''''''''''''''''''''''''''''
Hope this helps.
Good Luck!
 
G

Guest

Hi, Becky.

I don't understand why your Task and Task Details forms need to be on Form 1
nor how Form 1 can be in Datasheet view if it's unbound, but if you're trying
to sync a one-to-many relationship between Form 2 and Form 3, drag Form 3 to
Form 2, set the LinkMasterFields and LinkChildFields properties
appropriately, and then embed this form on Form1.

Hope that helps.
Sprinks
 
G

Guest

Sorry my mistake.
It would be better if the code was under the On Open event of the parent form.
 

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