473,394 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 2576
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.