Solved

Check for any enabled field data not entered

Posted on 2002-05-14
3
139 Views
Last Modified: 2010-05-18
Hi i want to do a loop with condition, to check for all enabled field are enter with data before proceed with next step (cos i have disabled some field). And it will prompt a msg box to re enter the blank field and when press okay will go back to the previous form
My field including option button, text box and combo box.

Thanks in advance
0
Comment
Question by:LHS
[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
3 Comments
 

Accepted Solution

by:
CarlJWhite earned 50 total points
ID: 7011169
This code will loop through the controls on you form and if they are a combo box/textbox/option and contain no data then display a message box. for the option button it checks whether it has been selected.

hope it helps

Dim ctl As Control
Dim blnError As Boolean
Dim strErrMessage As String

strErrMessage = "Please fill in these fields" & vbCrLf



For Each ctl In Form1
       
        If ctl.Enabled = True Then
        If (TypeOf ctl Is TextBox) Then
           If ctl.Text = "" Then
               strErrMessage = strErrMessage + ctl.Name & vbCrLf
               blnError = True
           End If
        End If
        If (TypeOf ctl Is ComboBox) Then
          If ctl.Text = "" Then
               strErrMessage = strErrMessage + ctl.Name & vbCrLf
               blnError = True
           End If
        End If
        If (TypeOf ctl Is OptionButton) Then
          If ctl.Value = False Then
               strErrMessage = strErrMessage + ctl.Name & vbCrLf
               blnError = True
           End If
        End If
       
        End If
 
 Next ctl


If blnError = True Then
MsgBox strErrMessage
End If
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7765513
Hi LHS,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept CarlJWhite's comment(s) as an answer.

LHS, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7838178
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

729 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