473,769 Members | 5,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2594
On 19 Sep 2006 19:45:33 -0700, "superjacen t" <su*********@gm ail.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, "superjacen t" <su*********@gm ail.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.Captio n and txtColnn.Contro lSource 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.Captio n and txtColnn.Contro lSource 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.Captio n and txtColnn.Contro lSource accordingly - making
.Visible=Tru e 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
15343
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 <> "TheOneIWantToKeep" Then Me.Controls.RemoveAt(i) End If
2
1687
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 appreciated!!!! Thanks,
9
8324
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 records in the database. Is it possible to create a SQL Server database using vb.net? I know I can use vb.net and ADOX to create a Access database. But I can't create SQL database using vb.net.
3
1812
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 when the user saves the data I can use the data already in the datagrid. Typically the user will add several rows before the DataSet.HasChanges is called and the DataAdapter.Update(AllChanges) is called. I want to add an employee number to each...
4
1647
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 shows a scenario where it was determined that cDerivedA is needed based on a configuration file. Dim lInstance As New cBase()
2
1818
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}", i++); ddlCate.DataSource = tblSub1; ddlCate.DataTextField = tblSub1.Columns.ColumnName; ddlCate.DataValueField =
4
11337
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. Thanks in advance.
0
1232
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 i send a request to the remote machine, the software finds the no.of databse (sql)in & it display in the local sys and want to backup and store in the local machine, so my qns is how programically backup and restore an sql databse...my front end...
4
6916
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 function creates the file as expected. When I loop through my array I get the error - "ArgumentException was unhandled - Illegal characters in path" The value "C:\Temp.txt" is the first value in the array - as it works
1
3379
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: 1) export to excel button exports the visible columns from the datagridview to excel (this works fine)
0
9416
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9979
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.