473,654 Members | 3,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referencing a form using a variable for the form name

9 New Member
I have a Function in a Module that takes in a parameter. From my form, I call that function and pass my form name. I'm trying to use forms!formname. Controls in the function and I get the error:

Access can't find the form 'FormName' reffered to in macro express of vb code

The code in the form that calls the function is:
Check_Req_Field s "tbAddDocum ent"
And the code in the function:

Function Check_Req_Field s(FormName As String)

For Each ctrl In Forms!FormName. Controls
If TypeName(ctrl) = "TextBox" Then
If ((IsNull(ctrl.V alue)) Or ctrl.Value = "") And (ctrl.Tag = "req") Then
err = err + 1
MsgBox "Please enter a value for " & ctrl.Name
Exit For
End If
End If
Next ctrl


Thank You
Nov 4 '08 #1
2 5114
Stewart Ross
2,545 Recognized Expert Moderator Specialist
There is an error in the way you are accessing the forms collection - it should be Forms(formname) to use the value of your formname variable, not
forms!formname, which will try to access a (nonexistent) form called formname. The variable's value cannot be substituted for the name of the variable when referring to forms using the ! notation.

-Stewart
Nov 4 '08 #2
ejamnadas
9 New Member
Thank you for pointing that out Steve. I do appreciate it.

Elesh
Nov 5 '08 #3

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

Similar topics

6
11276
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header" Src="WebControls/Header.ascx" %> The web user control contains the following server controls
5
1797
by: Amelyan | last post by:
I am struggling here trying to determine what is a good programming practice as far as referencing your URLs. When you use Response.Redirect, do you use 1) Hard-coded string -- Response.Redirect("MyPage.aspx"); 2) Constants -- Response.Redirect(STRMyPage); // where input parameter is -> const string STRMyPage = "MyPage.aspx"; 3) Something entirely differnent?
2
1598
by: mdiddy | last post by:
I'm learning vb, coming from a Perl background. I want to know how to reference a form element by using a counter variable in the element's name. For instance, let's say I have a form with 10 textboxes named textbox1 through textbox 10 and I have a for loop and I want to populate the text in the textboxes with the numbers 1 through 10 and I want to reference the textbox names by using the counter, something like this for x = 1 to 10...
6
2742
by: Mat | last post by:
Dear all, What I want to do is be able to use a string to refer to a control on a subform. IE: Forms!("Form1!form2!controlA").name or
3
1413
by: libsfan01 | last post by:
Hi all whats wrong with this script? i have named a form text box dynamically using php each row has a textbox called q101, q102 ... etc and i want to make sure my users dont input a quantity greater than the value of that box. to know which box applies to which of the products i have used a radio button which contains the id of the product which corresponds to the name of the box when a q is added to the front (javascript seems not to...
21
5093
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,...
2
1436
by: HankD | last post by:
Hi, I am having a problem with instantiating two custom objects so they DO NOT point to the same memory location. What is happening is that changes I am making to my object1 are changing object2. I beleive this is because I set both to be equal to the same session variable. So when I change the value in test1.name it updates test2.name as well as the session variable itself. What I want to do is keep an "ORIGINAL" copy of the data in case...
3
3956
by: rls03 | last post by:
I have the following which creates a variable containing a relative path where <xsl:value-of select="."/returns a portion of the filename: <xsl:variable name="fileName">../../data/models/<xsl:value-of select="."/>.xml</xsl:variable> I want to use this variable as an argument of the document function: <xsl:apply-templates mode="coordinates" select="document( REFERENCE
5
2087
by: Diego Pino | last post by:
Hello, I am experience some problems reading a form variable from a Javascript function. The point with this particular variable is that its name has the following syntax: <input name="tx_impexp"/> I want to set this var to 1 from my javascript function, so I tried to execute the following line of code:
0
8815
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
8708
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...
0
7307
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
5622
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
4149
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
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
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
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1596
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.