?
Solved

Create an error log

Posted on 2001-06-14
17
Medium Priority
?
169 Views
Last Modified: 2010-05-02
I am iterested in creating a log of all empty text boxes on several different forms.  I want it to run through and check to make sure each box is field in and if not put it in a log.  I know that I could make a check for each textbox, but is there anyway to do a run through to search all textboxes without calling each text box by its name?

Thanks
0
Comment
Question by:Lucree
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 4
  • 2
17 Comments
 
LVL 4

Accepted Solution

by:
beckingh earned 400 total points
ID: 6192328
Option Explicit

Private Sub Command1_Click()
    Dim Ctrl As Variant
    For Each Ctrl In Controls
        If TypeOf Ctrl Is TextBox Then
            If Ctrl.Text = "" Then
                MsgBox "Control Name: " & Ctrl.Name & " is empty"
            End If
        End If
    Next
End Sub
0
 

Author Comment

by:Lucree
ID: 6192392
it is not finding the textboxes for some reason!
0
 

Author Comment

by:Lucree
ID: 6192398
it is not finding the textboxes for some reason!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

by:beckingh
ID: 6192419
Where are you calling the loop from?  If it is outside of a form you will need to qualify controls with the name of the form...

i.e. if your form name is Form1

   For Each Ctrl In Form1.Controls
0
 

Author Comment

by:Lucree
ID: 6192445
it is not finding the textboxes for some reason!
0
 

Author Comment

by:Lucree
ID: 6192451
it is not having any trouble looping through the controls, just not finding a textbox. so nothing happens.
0
 

Author Comment

by:Lucree
ID: 6192471
it is not having any trouble looping through the controls, just not finding a textbox. so nothing happens.
0
 

Author Comment

by:Lucree
ID: 6192485
it is not having any trouble looping through the controls, just not finding a textbox. so nothing happens.
0
 
LVL 4

Expert Comment

by:beckingh
ID: 6192491
Go to the properties window for one of your forms.  Drop down the listbox right below "Properties - FormName" and see what the type of your "textboxes" are.  They may actually be MaskedBox or something else.

The other option is to try to look at all the controls and if they have a Text property, check if it is = "".

But if you just want to check textboxes this is the best way.



0
 
LVL 2

Expert Comment

by:chandukb
ID: 6192495

Try diclaring Ctrl as Control

Dim Ctrl As Control

   For Each Ctrl In Me.Controls  'Me is the current form
       If TypeOf Ctrl Is TextBox Then
           If Ctrl.Text = "" Then
               MsgBox "Control Name: " & Ctrl.Name &
                        " is empty"
           End If
       End If
   Next

Chandu
0
 
LVL 4

Expert Comment

by:beckingh
ID: 6192499
Go to the properties window for one of your forms.  Drop down the listbox right below "Properties - FormName" and see what the type of your "textboxes" are.  They may actually be MaskedBox or something else.

The other option is to try to look at all the controls and if they have a Text property, check if it is = "".

But if you just want to check textboxes this is the best way.



0
 

Author Comment

by:Lucree
ID: 6192570
I am actually trying to do it in Excel.  I cant get it to reconize a type for some reason.  I tried it in VB and it works fine.  Trying to get it to work in Excel now!
0
 
LVL 2

Expert Comment

by:chandukb
ID: 6192579
In Excel, you mean u have a form in excel with text boxes.

please provide more info.

Chandu
0
 

Author Comment

by:Lucree
ID: 6192595
yes a from in excel.  what it is doing is. It will count the number of controls and do the loop that many times, but it will not cycle through each control for some reason! So if I have 38 controls on 1 form it will do the loop 38 times stuck on the userform.
0
 

Author Comment

by:Lucree
ID: 6192614
yes a from in excel.  what it is doing is. It will count the number of controls and do the loop that many times, but it will not cycle through each control for some reason! So if I have 38 controls on 1 form it will do the loop 38 times stuck on the userform.
0
 

Author Comment

by:Lucree
ID: 6192671
I mean a Form not a from.  A form inside of an excel program.  I am sorry about the double posts.  I have been hitting the refresh button and everytime I press it send the message again.
0
 

Author Comment

by:Lucree
ID: 6192968
I set the Ctrl equal to an object and placed the object into a TypeName().



Dim AButton As Object
Dim Ctrl As Control

  For Each Ctrl In Controls
     Set AButton = Ctrl
     MsgBox "you clicked on me. I am a " & TypeName(AButton)
  Next

Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question