By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,025 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,025 IT Pros & Developers. It's quick & easy.

Programically Create Sub-Form - attach to Parent Form

P: n/a
Hope someone can help.

I have a saved parent form containing an unbound sub-form. I set the
SourceObject (form) after the Parent Form opens/loads.

The sub-form (datasheet view) basically displays the results of a
cross-tab query The cross-tab query is created dynamically (in code)
as the column headings are subject to change.

I therefore have to create a new form (in code) and add the necessary
controls (fields) as per the fields in the cross-tab query.

The reason why I want a form as the SourceObject of the sub-form is
that it allows Event Procedures to be activated. Using a straight
query (in my case a cross-tab query) as the SourceObject, I can't see
how I can activate any click or double-click events in the query cells
(I hope I'm wrong about this).

I've now noticed that this approach doesn't work in an MDE file as the
design mode is off.

Any suggestions or work-arounds.

Steve.

Sep 20 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 19 Sep 2006 19:45:33 -0700, "superjacent" <su*********@gmail.com>
wrote:

It is true that there is no code generation in MDE. Thank Bill for
that :-)
If you MUST have MDE, you have to relax your requirements.

I haven't tried, but perhaps you can create a subform with the maximum
number of fields, and then bind them on the fly based on how many
columns your crosstab outputs.

-Tom.

>Hope someone can help.

I have a saved parent form containing an unbound sub-form. I set the
SourceObject (form) after the Parent Form opens/loads.

The sub-form (datasheet view) basically displays the results of a
cross-tab query The cross-tab query is created dynamically (in code)
as the column headings are subject to change.

I therefore have to create a new form (in code) and add the necessary
controls (fields) as per the fields in the cross-tab query.

The reason why I want a form as the SourceObject of the sub-form is
that it allows Event Procedures to be activated. Using a straight
query (in my case a cross-tab query) as the SourceObject, I can't see
how I can activate any click or double-click events in the query cells
(I hope I'm wrong about this).

I've now noticed that this approach doesn't work in an MDE file as the
design mode is off.

Any suggestions or work-arounds.

Steve.
Sep 21 '06 #2

P: n/a
Initially I was using a saved form and programically removing and
adding controls as needed. Eventually this approach didn't work,
after a few days, after heaps of testing an error message claimed that
I'd used all the controls available. I suppose Access keeps a record
of previously deleted controls and I exceeded the limit.

So then I decided to programically create the sub-form from scratch and
therefore avoid the too many controls issue as mentioned above. This
failed in that I can't use this approach in an MDE (hence the posting).

I suppose what you suggest is do-able, using a saved form, that
contains, say a 100 controls (would never need that many - would be
between 12-20) and set the record sources etc when needed. I didn't
think of that approach a few days ago, as I would have tried it.

I've since solved my problem by utilsing a listbox as the displaying
object and changing the row soure, columnwidths, columncount etc as
required for the cross-tab. I shied away from this approach at the
start as it seemed like a lot of work to double-click on particular
row/column. In the end I had no choice and subsequently messed around
with the mousedown and doubleclick events to achieve what I wanted.

Thanks for your input and advice.

Steve.
Tom van Stiphout wrote:
On 19 Sep 2006 19:45:33 -0700, "superjacent" <su*********@gmail.com>
wrote:

It is true that there is no code generation in MDE. Thank Bill for
that :-)
If you MUST have MDE, you have to relax your requirements.

I haven't tried, but perhaps you can create a subform with the maximum
number of fields, and then bind them on the fly based on how many
columns your crosstab outputs.

-Tom.

Hope someone can help.

I have a saved parent form containing an unbound sub-form. I set the
SourceObject (form) after the Parent Form opens/loads.

The sub-form (datasheet view) basically displays the results of a
cross-tab query The cross-tab query is created dynamically (in code)
as the column headings are subject to change.

I therefore have to create a new form (in code) and add the necessary
controls (fields) as per the fields in the cross-tab query.

The reason why I want a form as the SourceObject of the sub-form is
that it allows Event Procedures to be activated. Using a straight
query (in my case a cross-tab query) as the SourceObject, I can't see
how I can activate any click or double-click events in the query cells
(I hope I'm wrong about this).

I've now noticed that this approach doesn't work in an MDE file as the
design mode is off.

Any suggestions or work-arounds.

Steve.
Sep 21 '06 #3

P: n/a
Per superjacent:
>The sub-form (datasheet view) basically displays the results of a
cross-tab query The cross-tab query is created dynamically (in code)
as the column headings are subject to change.

I therefore have to create a new form (in code) and add the necessary
controls (fields) as per the fields in the cross-tab query.
When I do reports based on cross-tab queries (columns=dates, for instance) I
create a report with more columns and column headers than I'll ever need.

I name them txtColnn and lblColnn and set .Visible=False.

In Report_Open, I open up .RecordSetClone, iterate through .Fields(i).Name and
let lblColnn.Caption and txtColnn.ControlSource accordingly - making
..Visible=True while I'm at it.

--
PeteCresswell
Sep 21 '06 #4

P: n/a

(PeteCresswell) wrote:
Per superjacent:
When I do reports based on cross-tab queries (columns=dates, for instance) I
create a report with more columns and column headers than I'll ever need.

I name them txtColnn and lblColnn and set .Visible=False.

In Report_Open, I open up .RecordSetClone, iterate through .Fields(i).Name and
let lblColnn.Caption and txtColnn.ControlSource accordingly - making
.Visible=True while I'm at it.
Yes, that all makes sense.

Steve.

Sep 21 '06 #5

P: n/a
Per superjacent:
>In Report_Open, I open up .RecordSetClone, iterate through .Fields(i).Name and
let lblColnn.Caption and txtColnn.ControlSource accordingly - making
.Visible=True while I'm at it.

Yes, that all makes sense.
Never tried it with a form... but it seems like it ought to work.
--
PeteCresswell
Sep 21 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.