473,657 Members | 2,556 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two Experts Meet

27 New Member
NeoPa:
This thread starts with an answer from a separate thread (Insert Existing Fields to a Form through code or macro), but it continues in a way that is neither relevant nor helpful to that thread.

Nevertheless, it is a valid discussion that may prove helpful in its own right - especially to the more experienced Access developers among us :-)
I use a similar technique to ADezii but I create the form with around 50 textboxes plus associated labels plus 50 labels in the header and 50 textboxes in the footer - so around 200 controls altogether.

Labels are named in a similar way T0, T1, T2 etc for textboxes, L0, L1 for associated labels, H0, H1.. for header labels and as you may guess F0, F1 etc for the footer textboxes.

50 may seem to be overkill, but I have had occasions where that number is required.

All controls are visible, but left, top, width and height are all set to 0. Textbox control sources are left empty

All form views allowed are allowed.

This technique also works with .accde

The technique is similar to that used for dynamic reports based on crosstabs

in the form on load event, you have code along these lines

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim fld As DAO.Field
  3. Dim i As Integer
  4.  
  5. Me.RecordSource = Me.OpenArgs 'pass name of query or sql in the openargs parameter of docmd.openform
  6. i = 0
  7. For Each fld In Me.Recordset.Fields
  8.     With Me("T" & i)
  9.         .ControlSource = fld.Name
  10.         .Move (i * (2000 + 60), 0, 2000, 300   'change these to suit positioning - 60 is a touch over 1mm and provides a margin between controls
  11.    End With
  12.    'do the same for labels
  13.     i = i + 1
  14. Next fld
  15. End Sub
There is potentially a lot more you might want to do in configuration - change form view, add code to a control event, add conditional formatting or change other control properties such as backcolor, forecolor, font etc. Can also apply code to resize width of control dependant on contents. Pretty much all the sorts of things you might want to do with a specifically designed form.
Aug 17 '22 #1
6 5883
isladogs
459 Recognized Expert Moderator Contributor
Hi CJ_L
Good to see you here providing expert advice at Bytes.com

Can you clarify when you use this kind of approach
Aug 17 '22 #2
NeoPa
32,568 Recognized Expert Moderator MVP
How do I say this without giving away information I shouldn't give away? I know Colin Riddington's (isladogs) identity is public here so I'll start with :
You two know each other. Do you both realise that?
Aug 18 '22 #3
isladogs
459 Recognized Expert Moderator Contributor
Yes, we both know each other well.
CJ_L is one of the presenters for the Access Europe User Group, a moderator at another forum and has expert knowledge of his subject
Aug 18 '22 #4
CJ_London
27 New Member
yup, we go back a few years!

Hi Colin

An example you have seen is Access Studio - it is used to display the lists of tables and fields, the drop downs for templates and queries and of course displaying multiple query results. There was another one not available in the released version to select and add projects. These are all subforms and not populated in the way I described above as not relevant to the OP's question. All those subforms, all using the same sourceobject.

A form is a class and I treat this form as such. It contains no event code, only formatting code and I use this like a class, using sets and lets to pass through the recordsource (which can be a value list), the view required (continuous, datasheet, single) whether to show tickboxes (for multi select) , etc. At the moment it only contains labels and textboxes (you've seen my example for colourful/resizeable tickboxes which uses a textbox) and currently considering adding an image control.

The first 4 could use listboxes and combo's instead, and the queries could use a querydef but I wanted the ability to do more with the presentation - not implemented in the version you have seen, but for example the ability to lift the subform off the main form into another instance as a popup - so you could view table or fields side by side - and images if I implement it.

But the primary purpose is to display the results of a query generated by a user via a user interface - such as the sql editor in Access Studio or dynamic crosstabs. Appreciate that can be done by creating a temporary query and assigning it to a subform recordsource, or opening directly but it may be I want to display the results as a continuous form for better presentation or I need to include some additional functionality such as conditional formatting or control events which you can't do with a query object.

Final example would be a combo where I want to display say first, last and full name. I can use two subforms, one to display the selected record and the other as the dropdown. Again - I could use two additional textboxes that reference the the combo columns, but again it comes down to presentation.
Aug 18 '22 #5
isladogs
459 Recognized Expert Moderator Contributor
Yes I thought that Access Studio would be one of the primary uses.

For the benefit of other readers, I think its fair to say that such usage scenarios are non-standard ways of stretching the capabilities of Access to provide additional functionality. Access Studio is a great product which was demonstrated to the Access Europe User Group in April
A free 'starter edition' can be downloaded from my website: Access Studio.
I strongly recommend it.

However, in the context of the OP of the original thread, such usage shouldn't be necessary
Aug 18 '22 #6
CJ_London
27 New Member
For how I am using it I don't disagree - but the solution I provided in the thread (post #1 on this one) was a very simple example for a dynamic form which avoids the need for a user to create a form and controls.

I wonder if there is any chance to Insert Existing Fields to a Form via a VBA code.. Because I created the table using import from excel and the field name may vary each time depending on the excel file heading rows.

You could just as easily use a query, but the OP was asking for a form - I presume a continuous form
Aug 18 '22 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

53
3984
by: ROSY | last post by:
hello, response if u ,on all level of questions::: 1.how a self deletable .exe file deleted on some future date & time without invoking the .exe itself? 2.if we want that any wildcard characters in command line arguments should be appropriately expanded,are we reqd. 2 make any special provision?if yes,which? 3.why :: printf("%%%%%") ; output %%%. 4.how 2 run a .obj file without previously creating any .exe?
68
3184
by: Gsec | last post by:
Hi, Can anybody let me know how to write a infinite loop, such that the program never crashes ? I, guess, buffer overflow method mite help!Not sure. Plz let me know. -thanks and regards,
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
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
8827
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
8732
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
8503
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,...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1620
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.