473,395 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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)then...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 1506
On Fri, 16 Jul 2004 17:46:24 GMT, "Enterprise" <so*****@microsoft.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)then...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*****@microsoft.com> wrote in message
news:Qv*****************@newsread2.news.pas.earthl ink.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)then...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*****@microsoft.com> wrote in message
news:Qv*****************@newsread2.news.pas.earthl ink.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)then...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
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...
1
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...
3
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> ...
4
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
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...
6
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...
7
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...
4
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...
11
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.