[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Create an error log

Posted on 2001-06-14
17
Medium Priority
?
171 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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