[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

If Then Loop MS WORD VBA

Asked by astring in Microsoft Word

Tags: MS WORD VBA

I am having a brain freeze here.  I open a data collection form on opening a new doc from a template.  I need to check the text box (AltClientRepName) for data and if it is blank, confirm the user wants it to be blank.  If so, clear the remaing 3 text boxes and set all 4 variables to a space.  Easy enough.

My problem arises if the user wants AltClientRepName to be filled out, responding yes, but then leaves one of the other 3 text boxes blank.  I cannot come up with a solution that always checks these text boxes for data if the response is Yes without doing a complete Response/If/Then series for each of the remaining 3 variable text box.  These need to be checked for data if AltClientRepName is not left blank.  As it is now the process would never enter the IF/Then in the first place.  If AltClientRepName is not left blank, (meaning the additional info is required) the remaining 3 text boxes do not get checked for data.

There must be a better way!!  Commented out code is provided for additional information about the variables and text boxes.  I have also attached a text file with the complete event code for the on click event for additional clarification.  It's not pretty, but it works, sort of.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
If [txt_AltClientRepName] = "" Or IsNull([txt_AltClientRepName]) Then
             Msg = "Do you want to leave Alt Rep Name Blank?"    ' Define message.
             Style = vbYesNo + vbCritical + vbDefaultButton2    ' Define buttons.
             Title = "Blank Alt Rep Name"    ' Define title.
             Response = MsgBox(Msg, Style, Title)
             
             If Response = vbYes Then    ' User chose Yes.
                 .Variables("AltClientRepName").Value = " "
                 [txt_AltClientRepName] = " "
                 .Variables("AltClientRepPhone").Value = " "
                 [txt_AltClientRepPhone] = " "
                 .Variables("AltClientRepFax").Value = " "
                 [txt_AltClientRepFax] = " "
                 .Variables("AltClientRepEmail").Value = " "
                 [txt_AltClientRepEmail] = " "
                 
             Else    ' User chose No.
                 [txt_AltClientRepName].SetFocus
                 Exit Sub
             End If
         End If
        
'        If [txt_AltClientRepPhone] = "" Or IsNull([txt_AltClientRepPhone]) Then
'            MsgBox "You must enter an Alt Client Rep Phone."
'             [txt_AltClientRepPhone].SetFocus
'            Exit Sub
'        Else
'            .Variables("AltClientRepPhone").Value = [txt_AltClientRepPhone].Text
'        End If
        
'        If [txt_AltClientRepFax] = "" Or IsNull([txt_AltClientRepFax]) Then
'            MsgBox "You must enter an Alt Client Rep Fax."
'             [txt_AltClientRepFax].SetFocus
'            Exit Sub
'        Else
'            .Variables("AltClientRepFax").Value = [txt_AltClientRepFax].Text
'        End If
       
'        If [txt_AltClientRepEmail] = "" Or IsNull([txt_AltClientRepEmail]) Then
'            MsgBox "You must enter an Alt Client Rep Email."
'             [txt_AltClientRepEmail].SetFocus
'            Exit Sub
'        Else
'            .Variables("AltClientRepEmail").Value = [txt_AltClientRepEmail].Text
'        End If
Attachments:
 
Complete code for on click event
 
[+][-]10/12/09 05:22 AM, ID: 25550521Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Microsoft Word
Tags: MS WORD VBA
Sign Up Now!
Solution Provided By: GrahamSkan
Participating Experts: 2
Solution Grade: A
 
[+][-]10/10/09 05:53 AM, ID: 25542128Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/10/09 07:56 AM, ID: 25542495Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/10/09 03:34 PM, ID: 25544141Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/12/09 01:46 AM, ID: 25549434Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/12/09 04:21 AM, ID: 25550181Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/12/09 04:25 AM, ID: 25550196Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625