Replicate a Split Form (1 Viewer)

AJR

Registered User.
Local time
Today, 16:48
Joined
Dec 22, 2012
Messages
59
Hi

This is a pretty bonehead question but I'm at the point where it needs to be asked. I could do this as a split form (I seem to loose control over the font size that way) but the real problem is that I just don't understand the workings of the Master and Child link on a form so now seems like as good a time
as any to learn. I have tried everything I could think of and searched high and low for an answer with no luck whatsoever. Any help would be greatly appreciated -- it seems like it should be a simple thing
to accomplish. I'm just a dabbler with a tiny bit of experience with VBA


Background

I have a table of Stocks. Each record contains a field for Stock Ticker and, amongs others, one for Type of Stock (e.g., Tech, Commodity). I want to have a form with which I can review stocks from only one category, say Tech. I would like this form to have a list of all the Ticker Symbols for the category on the right side of the form. I would click on a Ticker and the fields on the form would show data from that record. Again, this is exactly what a split form can do very easily.

My Solution

I have a query that returns only records from the required Category (e.g., Tech) and contains all the otherf ields I need, including the Ticker Symbol.

I have a form (Single Form view) That has all the fields I want to look at for each stock and uses the Query as it's Record Source.

I have inserted into this form a subform (Datasheet view) that uses the same Query as the main form and contains only one field, the Stock Ticker.

The Problem

I cannot get this to perform the way I would like. Which is again, to allow me to click on a Ticker Symbol on the Subform and have the Master Form show data from that Tickers record.


Many Thanks if you have even bothered to read this far.

AJR
 

MarkK

bit cruncher
Local time
Today, 01:48
Joined
Mar 17, 2004
Messages
8,183
What you might try is add a listbox to your form to replace your subform, and if you have wizards enabled, it will actually prompt you to set it up so you can use the list to find a record in your form, which is what it sounds like you want to do. Then you can just tweak the listbox and the code the wizard writes to do what you want. I think. Give it a try. Make sure wizards are enabled.
 

AJR

Registered User.
Local time
Today, 16:48
Joined
Dec 22, 2012
Messages
59
Thanks for the suggestion. I had not thought of that approach and it will probably be a more suitable solution. Still do not understand why the linked subform does not work though.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 18:48
Joined
Jan 20, 2009
Messages
12,852
It can be done by putting two subforms on an empty main form. The main form does not need a RecordSource.

The list subform is a Datasheet or Continuous Form while the other is a Single Form.

Put a textbox on the mainform with its ControlSource as the field or control in the list subform. Use this textbox as the MasterLinkField for the other subform. The textbox can be hidden but I find it useful as a heading.

While it is possible to point the LinkMasterField directly to a field or control on the list subform it can cause loading problems with errors if the single form subform loads first.

BTW. A LinkMasterField need not even be on the same main form. They even work fine pointing to an entirely different form except they do not track until the subform is requeried. This technique can be useful of the code-shy to make a popup edit form.

Note however the LinkChildField must be a field in the subform's recordset. It is really a lot simpler than it seems in the Wizard. Just take a look at the properties.

Also you have definitely made a good step to eschew Split Forms. They have many more limitations and can be quite intractible when attempting to automate them because they don't expose their object model properly.
 

AJR

Registered User.
Local time
Today, 16:48
Joined
Dec 22, 2012
Messages
59
Galaxiom

Thanks a lot for this. It explains a lot on many different levels. I have been distracted for a few days and will now dive into this again. Really appreciate your help

AJR
 

Users who are viewing this thread

Top Bottom