How to Emulate Split Form (1 Viewer)

JamesJoey

Registered User.
Local time
Today, 16:20
Joined
Dec 6, 2010
Messages
608
I've been using split forms for some time now with the datasheet on the left and the single form part on the right.

I find many small annoyances with split forms.

I want to emulate them using a continuous form as a subform of a single form with the single form based on the same table as the subform so I can select a row in the continuous subform and shw the pertinent data for the record on the right.

Not sure if I need 2 subforms on a main form or preferably the continuous subform only on the main form.

Any help will be appreciated.
James
 

Ranman256

Well-known member
Local time
Today, 16:20
Joined
Apr 9, 2015
Messages
4,339
make a parent form (single record)
then the 2 sub forms, (either continuous or single rec)
join the subforms to the parent via
LINK PARENT FIELD,
and
LINK CHILD FIELD
 

JamesJoey

Registered User.
Local time
Today, 16:20
Joined
Dec 6, 2010
Messages
608
So, I need to create 3 forms.
2 Single and one continuous.

All are based on the same table?

This is for my Auto Maintenance records.

I'm not really clear on how to link the Master and Child fields.

Which Form do I set this in?

The ID filed is called MtceID.
 

isladogs

MVP / VIP
Local time
Today, 21:20
Joined
Jan 14, 2017
Messages
18,209
make a parent form (single record)
then the 2 sub forms, (either continuous or single rec)
join the subforms to the parent via
LINK PARENT FIELD,
and
LINK CHILD FIELD

Hi ranman

Why like this?
Surely either a single record main form with a datasheet subform
OR do I mean vice versa

OR use an unbound main form as a container for two subform - single record & datasheet
 

JamesJoey

Registered User.
Local time
Today, 16:20
Joined
Dec 6, 2010
Messages
608
Ideally I would like to have a single form with a continuous subform.

When I select a row in the subform I want the data in the single form to display the info for that record.
 

isladogs

MVP / VIP
Local time
Today, 21:20
Joined
Jan 14, 2017
Messages
18,209
Ideally I would like to have a single form with a continuous subform.

When I select a row in the subform I want the data in the single form to display the info for that record.

That sounds fine to me - go for it

I'm not really clear on how to link the Master and Child fields.

In design view, click on the outline of the subform i.e. the 'border'.
Then go to the property sheet data tab.
Click the ellipsis (...) button to the right of Link Master fields
The 'Subform field linker' opens



Enter a field in the master & child form areas (these don't have to have the same field name BUT the data MUST match)
Repeat if you want more than one 'pair'.
 

Attachments

  • SubformFieldLinker.PNG
    SubformFieldLinker.PNG
    14.7 KB · Views: 2,855

JamesJoey

Registered User.
Local time
Today, 16:20
Joined
Dec 6, 2010
Messages
608
I did that and now the continuous subform only displays the first record.

I have the continuous subform on the left side of a single form and the other fields in the table on the right.
 

JamesJoey

Registered User.
Local time
Today, 16:20
Joined
Dec 6, 2010
Messages
608
Both the single form and the continuous subform are based on the same table and are based on select statements the pull all fields form the table.

The example is a bit more complicated than I wanted.

I imagined it to be a bit simpler than that.

I accomplish the same thing using a single form with a list box.
The list box has only one column and when select a row the single form goes to that record. But, in that case I am simply using FindFirst coding on the AfterUpdate of the list box.
Why can't I replace the list box with a continuous subform and accomplish the same thing ??
I've tried using the same code in the list boxes after update but I can't get it to worked with a continuous form.

I appreciate the assistance but if I need to go through all this with all 9 of my tables it doesn't seem worth it.

I guess I can put up with Split form's shortcomings.
 

isladogs

MVP / VIP
Local time
Today, 21:20
Joined
Jan 14, 2017
Messages
18,209
For info, I abandoned split forms years ago as I found they were difficult to manage. However I didn't try to emulate them - I just gave up on the concept

Sorry - I hadn't looked at the example properly so had no idea how it was being emulated.

In the circumstances, I agree - put up with their shortcomings or abandon them

However, for my own interest, I'll have a play & see if I can solve it using a single form & a continuous form. If I can, I'll let you know
 

JamesJoey

Registered User.
Local time
Today, 16:20
Joined
Dec 6, 2010
Messages
608
I like to try different things with access.

Currently I'm using continuous forms with editing forms.
I'm able to manipulate them more easily. Even for someone like me who don't what he's doing.

Thanks much for the effort, it's appreciated,
James
 

isladogs

MVP / VIP
Local time
Today, 21:20
Joined
Jan 14, 2017
Messages
18,209
I agree - continuous forms are far easier to use.
Good luck & keep experimenting ... but also worth knowing when to give up
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 06:20
Joined
Jan 20, 2009
Messages
12,851
Emulating a split form is dead easy and doesn't require any code at all.

Unbound main form with two subforms having the same RecordSource. Continuous form for selecting, single form for editing.

Place a textbox on the main form with the ControlSource:
Code:
= continuoussubformcontrol.Form.keyfieldname
This textbox now tracks the current record in the Continuous subform.

On the single form subformcontrol, set the MasterLinkFields as the name of the textbox on the main form. Set ChildLinkFields as the name of the key field in the subform RecordSource. This subform now tracks the mainform textbox.

It is even possible to run this without the mainform textbox by entering the continuous subform key field as the MasterLinkFields.
Code:
 Parent.continoussubformcontrol.Form.keyfield
However this arrangement will throw errors during loading if the editing form loads before the selecting form.
 

isladogs

MVP / VIP
Local time
Today, 21:20
Joined
Jan 14, 2017
Messages
18,209
Hi G

Is it really that easy?

I referred the OP to the example by Speakers86 in Sample Db area without testing it myself.
It turns out that one is more complicated using lots of key down events to keep track of the forms

I've just wasted an hour trying various other means of tracking events between:
a) a main single form & a continuous subform
b) an unbound main form with 2 subforms

Will try your method tomorrow
Thanks
 

MarkK

bit cruncher
Local time
Today, 13:20
Joined
Mar 17, 2004
Messages
8,179
Simpler still, just set everything to use the same recordset. Open a main form, then load a subform in datasheet, then set the subform's recordset to the same object as the main form's recordset.
Code:
Private Sub Form_Open(Cancel As Integer)
[COLOR="Green"]'   This is the main form open event handler[/COLOR]
    Me.RecordSource = "tTestData"            [COLOR="Green"]'set the recordsource of the main form[/COLOR]
    Me.sfm.SourceObject = "fTestDataDS"      [COLOR="Green"]'load datasheet subform w/ blank RecordSource[/COLOR]
    Set Me.sfm.Form.Recordset = Me.Recordset [COLOR="Green"]'set subform recordset to same object as main form's[/COLOR]
End Sub
Done. No more code, and sync is automatic, since both forms are leveraging the same recordset...
 

isladogs

MVP / VIP
Local time
Today, 21:20
Joined
Jan 14, 2017
Messages
18,209
Now that really is easy!
It took 2 minutes - mostly to remove the garbage code I had tried earlier

I used a continuous subform as I'd already created that

Attached a simple db with an emulated split form using Mark's code for the benefit of the OP (JamesJoey)

I'm sure he'll be back here passing on his thanks

Many thanks to both Greg & Mark for their contributions - I only wish you'd got involved earlier ...
 

Attachments

  • Emulate SplitForm - NEW.accdb
    488 KB · Views: 386

NauticalGent

Ignore List Poster Boy
Local time
Today, 16:20
Joined
Apr 27, 2015
Messages
6,321
Code:
Private Sub Form_Open(Cancel As Integer)
[COLOR="Green"]'   This is the main form open event handler[/COLOR]
    Me.RecordSource = "tTestData"            [COLOR="Green"]'set the recordsource of the main form[/COLOR]
    Me.sfm.SourceObject = "fTestDataDS"      [COLOR="Green"]'load datasheet subform w/ blank RecordSource[/COLOR]
    Set Me.sfm.Form.Recordset = Me.Recordset [COLOR="Green"]'set subform recordset to same object as main form's[/COLOR]
End Sub

To further the line on the EVIL nature of split forms, here is a thread I started a little while ago and decided I just do not need them despite how much the users love them.

CJ London offered a solution but I was too far gone to try it. This thread was inspired me, coupled with the current vacation I am on, I can't wait to get back to work and give it a go...
 

isladogs

MVP / VIP
Local time
Today, 21:20
Joined
Jan 14, 2017
Messages
18,209
Me too ... I've avoided split forms for years.

In response to a post on UA, I've just made a small db to store the page reference of forum posts that interest me so I can easily find them for future reference

Using Mark's code, I've done this with an emulated split form ... it works a treat.

The irritating thing is the solution was basically what I started with - single form & continuous subform with same recordsource and parent/child fields left blank. The one thing I had not done was this line:
Code:
Set Me.sfm.Form.Recordset = Me.Recordset
Leave that out & it doesn't work
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 16:20
Joined
Apr 27, 2015
Messages
6,321
In response to a post on UA, I've just made a small db to store the page reference of forum posts that interest me so I can easily find them for future reference.

Brilllant idea...
 

Users who are viewing this thread

Top Bottom