473,698 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referencing Forms

Hey..

I was just wondering why there are so many ways to reference a form and
what are the pros and cons of using each.

I've seen at least 5 different ways, which is correct (or in what
situations are each most correct)?

Private Sub cmdButton_Click ()
' This causes the same MsgBox to be displayed 10 times in A2K
' Line 9 has the added bonus of referencing form-specific controls
' from IntelliSense, the rest (well, the ones w/ the dot)give
' generic form props/meths

1 MsgBox Forms(0).Text0
2 MsgBox Forms(0)!Text0

3 MsgBox Forms("form1"). Text0
4 MsgBox Forms("form1")! Text0

5 MsgBox Forms.form1.Tex t0
6 MsgBox Forms.form1!Tex t0

7 MsgBox Forms!form1.Tex t0
8 MsgBox Forms!form1!Tex t0

9 MsgBox Form_Form1.Text 0
10 MsgBox Form_Form1!Text 0

End Sub

Nov 13 '05 #1
1 1661
I like consistency.
I use the dot, never the bang.
My forms always have code behind them.
The form object is public and accessible, regardless of its use.
The form object can be instantiated multiple times by creating an array
whose elements are instances of it: DimSomeForms(3) as Form_Form1.
The form object is always available; referring to it, opens it (if it
is not already open).
Public Properties of the form object are referred to and used just like
any other Properties.

I always use #9: Form_Form1.Text 0.

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2587
by: Tony Williams | last post by:
I have a form on which there is a tabcontrol and on this onr of the tabpages is a tick box which opens Outlook with data from the main form and prompts the user to amend the message before being sent. The code is Private Sub Loadtxt_Click() Dim oA As Outlook.Application Dim oM As Outlook.MailItem Set oA = CreateObject("Outlook.Application") Set oM = oA.CreateItem(olMailItem)
2
4764
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text box that references a field on the subform. What I'd like it to do is show the value in the field of the last record entered on the subform. But what its doing is referencing whatever record the user clicked on last before closing all the forms. Also if the user cleared the subform field, I would like the text box on the main...
6
2466
by: jstaggs39 | last post by:
I want to create a Dcount and an If...Then...Else statement to count the number of records in a table based on the date that is entered to run the form. The If....Else statment comes in because if the amount of records for a particular date is positive, i want the form to stop running, if there are no records that contain the date in question, then it should continue to run the form. The problem i'm having is referencing the date that is...
4
1848
by: mplogue | last post by:
I have a form (frmMain) with a subform (frmSub), each with enumerated fields of the same name (txt1, txt2, etc). I'm trying to make a function that will take the values for each field in frmMain, and put them in the same-named field in the subform. Here's the function: '--------Start Code-------- Function cmdFillSub() Dim i As Integer
2
4070
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I want to do this as I want to use same subform on two different parent forms. Main problem is that the subform is not part of the forms collection. The only workaround I found was setting the query in code in the
0
1101
by: Chris | last post by:
I want to display a formview based on an objectdatasource. One of the things on the formview will be a link to a pdf. When I go into the edit template I would like a fileupload to display, which can be used to upload a new pdf. I would like my object to be as reusable as possible. Can anyone recommend a way of referencing the fileupload control in as flexible way as possible. The thing I would like to avoid is using my object on several...
21
5095
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main form, the code errors out at the 2nd line. The error number is 13 and the description is "Type mismatch". Both controls are memo fields. I suspect that "Screen.ActiveControl.Parent" is not referencing the form as intended. Thanks for any help,...
5
1422
by: =?Utf-8?B?U3RlZmFuIEJhcmxvdw==?= | last post by:
I am experiencing a lot of speed issues on initial app loads where we are referencing 3rd party 1.1 assemblies from 2.0 code. Those 1.1 assemblies reference things like System.Windows.Forms (totally unnecessarily I might add). I'm assuming our memory footprint will practically double by re-loading the System, System.Web, System.Windows.Forms assemblies. This also causes a significant bottleneck. For example:
5
1375
kcdoell
by: kcdoell | last post by:
Good Morning: I am using the following code to add new records to a table that is on my Sub Form. Below is the code that I placed in my Before Update event on my Sub Form: Private Sub Form_BeforeUpdate(Cancel As Integer) 'When records are added it adds the coresponding LocationsID, YearID and Month IDs 'to the new record.
0
8675
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
8604
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,...
1
8897
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
6521
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
5860
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
4370
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...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.