473,834 Members | 1,682 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to go through a bunch of text boxes in a form.

Hi,
I have 25 text boxes in a form. Lets say TB1 through TB25 are the Names of
the boxes. They have no controll sources. I want to be able to check whether
the text box is empty. Is there anyway I can do this in a loop? The only way
I can see to do this is to go if isempty(TB1) then...endif if
isempty(TB2)the n...endif which will involve 25 if statements. I was kind of
hoping to do this in a for loop if possible.

Thanks
P.S. Using ACCESS 2000
Nov 13 '05 #1
4 1531
On Fri, 16 Jul 2004 17:46:24 GMT, "Enterprise " <so*****@micros oft.com>
wrote:
Hi,
I have 25 text boxes in a form. Lets say TB1 through TB25 are the Names of
the boxes. They have no controll sources. I want to be able to check whether
the text box is empty. Is there anyway I can do this in a loop? The only way
I can see to do this is to go if isempty(TB1) then...endif if
isempty(TB2)th en...endif which will involve 25 if statements. I was kind of
hoping to do this in a for loop if possible.

Thanks
P.S. Using ACCESS 2000


This will loop through the forms controls collection and identify
textboxes.

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If Len(ctl & "") = 0 Then
'Code here
End If
End If
Next
- Jim

Nov 13 '05 #2

"Enterprise " <so*****@micros oft.com> wrote in message
news:Qv******** *********@newsr ead2.news.pas.e arthlink.net...
Hi,
I have 25 text boxes in a form. Lets say TB1 through TB25 are the Names of
the boxes. They have no controll sources. I want to be able to check whether the text box is empty. Is there anyway I can do this in a loop? The only way I can see to do this is to go if isempty(TB1) then...endif if
isempty(TB2)the n...endif which will involve 25 if statements. I was kind of hoping to do this in a for loop if possible.

Thanks
P.S. Using ACCESS 2000


For I = 1 To 25
If Len(Me("TB" & I) & "") = 0 Then
Debug.Print "TB" & I & " was empty."
Else
Debug.Print "TB" & I & " contained: " & Me("TB" & I)
End If
Next I
Nov 13 '05 #3
Thank you VERY much. I have been taught in my first programming class to
make code look nice...and this would do it. Somehow 25 if statements just
didn't seem like good programming at all :-)
"Enterprise " <so*****@micros oft.com> wrote in message
news:Qv******** *********@newsr ead2.news.pas.e arthlink.net...
Hi,
I have 25 text boxes in a form. Lets say TB1 through TB25 are the Names of
the boxes. They have no controll sources. I want to be able to check whether the text box is empty. Is there anyway I can do this in a loop? The only way I can see to do this is to go if isempty(TB1) then...endif if
isempty(TB2)the n...endif which will involve 25 if statements. I was kind of hoping to do this in a for loop if possible.

Thanks
P.S. Using ACCESS 2000

Nov 13 '05 #4
Looping Through Fields In Unbound Forms
http://www.accessdatabasetips.com/lo...und-forms.html

Best regards,
J. Paul Schmidt, Freelance Access and ASP Web Developer
www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Demo, ASP Bar Chart Tool...
Nov 13 '05 #5

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

Similar topics

4
6317
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by the choice from the drop down box. Something like: <form name="populatefrm" id="contactfrm" method="post"
1
2160
by: Serious_Practitioner | last post by:
This is such a simple problem. I've asked for, and gotten, help with this in the past, and I can't make this work. Once more, please - I want to be able to put a member number (which is the primary key of a table called tblMemberInfo) into a text box on an unbound form and get back, in some other text boxes, other information (name, e-mail address and date of birth, say) from the same table. I also want to get, from a table called...
3
2510
by: duncan | last post by:
I have a text box on a web form here is the HTML for it :- <asp:textbox id="winPts" style="LEFT: 170px; POSITION: absolute; TOP: 80px" runat="server" Width="24px" maxlength="2"></asp:textbox> This is one of several such boxes. The problem I have is on my lap top using Viual Studio 2003 the text boxes display as intended. I have copied the source code across to my desktop and when I run the page using Visula Studio 2003 the form...
4
1104
by: Edward | last post by:
VB.NET I have a bunch of textboxes on my form txtPart1 txtPart2 .... txtPart16 When the user presses "Ok", I need to concatenate the values into a
7
4234
by: Andrew McKendrick | last post by:
Hi, I've noticed a bug in VB.NET (latest .NET Framework)... - I have a TabControl on a form with several tabs. - Each tab contains text boxes that are bound to fields in a data source (DataBindings). - When I display a record and then try to access the .Text property of one of the text boxes on any tab except the current tab, the result is an Empty string.
6
3439
by: BurntWithTime | last post by:
Hello everyone, Please can anyone tell me if it is possible for a VB.NET application to check a database and then create textboxes on a form that correspond to those records on the database? For example, say I had a table in a DB that contained movie subjects: Horror, Sci-Fi, Comedy etc. Would it be possile for the VB app to look at these and then create the text boxes Horror, Sci-Fi and Comedy? Thanks, BWT
7
4528
by: ljungers | last post by:
Have Form-1 with 3 text boxes and 1 command button. With any of the 3 boxes filled out and button is clicked, a Macro is performed that Opens a Query that has a WHERE clause that uses the 3 test boxes of data from form-1. 1) How do I cause the SQL command window not to show for that SQL command? The query results is placed in a ListBox on Form-2 and desired rows in the list box are selected/clicked, followed by a click on a button that...
4
2305
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post by:
I have created a report. This report needs to display records between two dates entered by the user. I put two text boxes on the report so I can enter the start and end date - I set them to use an input mask of 'short date' format. The problem is that when I enter anything in these text boxes, as soon as the field looses focus, the text is cleared out - thus the text box is left blank. I have a button on the form that calls the requery...
11
5203
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command button will open a new form (Form2). Form2 has two subforms. Both are embedded in the main form. (Subform2 is NOT embedded in subform1.) Subform1 displays records as a continuous form based on the Primary ID of the main form and lists the...
0
9643
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
10789
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
10504
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
10214
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9327
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...
1
7755
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
6951
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
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3975
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.