472,795 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,795 software developers and data experts.

Programically Create Sub-Form - attach to Parent Form

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
5 2503
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
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
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

(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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Merlin | last post by:
Hi, My code below doesn't work does anyone have any pointers? All my controls are programically added. Dim i As Int16 For i = 0 To Me.Controls.Count - 1 If Me.Controls(i).Name <>...
2
by: Daniel Friend | last post by:
Hello, I have added a custom usercontrol programically and all works fine... I would like to change some custom properties that I have set in that usercontrol. Any help would be greatly...
9
by: Peter | last post by:
Hello£¬everyone, My program will collect a testing machine's data ,save the data and deal with the data everyday. I want to use vb.net to create database, add and delete tables or modify the...
3
by: Jim | last post by:
I have a datagrid with a DataAdapter as the DataSource. The user fills in their data for 3 columns and I want to programically add a value to the 4th (invisible) column (employee number). That way...
4
by: Joe HM | last post by:
Hello - I have a Base Class where I want a New() implemented that can be called from the outside. This New() should create an instance of the appropriate cDerivedX Class ... The following...
2
by: dtarczynski | last post by:
Hello. Im trying to add new EventHandler to DropDownList programically. Im doing something like this: DropDownList ddlCate = new DropDownList(); ddlCate.ID = String.Format("ddlCategory{0}",...
4
by: Abdhul Saleem | last post by:
Hi, I am recieving error ActiveX component can't create object in the following line in the asp page. set ExcelApp = CreateObject("Excel.Application") Previously this code was working fine....
0
by: abduzalam | last post by:
Hi Members, I am in a serious trouble,My problem is i want to develop a software as my academic project, it is network back up database, that is a remote machine hold sql databses, and when...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.