Solved

Pausing Loop When Switch is Tripped for User Input

Posted on 2011-09-08
13
194 Views
Last Modified: 2012-06-27
Hello,

I am developing an Excel import script that is importing tables from Excel.  During this import process, I am checking the fields data type, format, and size.  That I have figured out.  But what I am trying to accomplish now is to make sure that the Field names are matching what is expected.

I have a variable for the expected field name checking against the field names within the table properties/tabledefs.  If there are no matches then it sets my variable: str_MatchSWX = "FAIL".  

What I would like to do is pause the loop when the variable = "FAIL".  THen get the user's input.  After the user reassigns the field name, the loop can start back up where it left off.

Is there a break that we can program into the VBA?

Best Regards,

Wendee
0
Comment
Question by:pwdells
[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
  • 4
  • 4
  • 3
  • +1
13 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 36506336
you can add a line that will show the input box

dim strField as string
strFIeld=inputbox("enter Name of field")

if strField & ""="" then  'no input
   ' what to do
   else
   'continue
end if
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36506340
Something like this?

If str_MatchSWX = "FAIL" Then
     msgbox "Click 'OK' once you have reassigned the field name", "OK", vbOkOnly
End if
0
 
LVL 10

Expert Comment

by:plummet
ID: 36506372
You could simply add an InputBox into the loop:

for .....
    ....
    .....
    if str_MatchSWX = "FAIL" then
        strReply = inputBox$("Please enter a new value","My title","Default value")
        ... (do something with the new value)
    end if

next

Open in new window


Does that idea make sense?
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:pwdells
ID: 36524391
Sorry for the delay.  My 1 year old daughter is in the hospital right now and I am working part-time from the hospital.  I have not had much of an opportunity to dig into this issue since your comments.  Please accept my apologies.

Wendee
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36524417
I'm sorry to hear that.  Take your time ...
0
 
LVL 10

Expert Comment

by:plummet
ID: 36524763
I'm sending you good wishes and hope that she recovers quickly.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36524840
Hope she recovers soon.. and bro, family first before job... so take your time
0
 

Author Comment

by:pwdells
ID: 36525025
Thank you, everyone.  

P.S. Cap, I am a girl!  :)
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36525064
Lol! I sympathize with you... I've been called everything from 'dude' to 'the Man' to 'brotherman', and I am none of the above. :-)
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36525077
oops, sorry Sis!!!
0
 

Author Closing Comment

by:pwdells
ID: 36561209
I had to work offline for awhile, so I could not check with Cap to confirm his answer.  So I had to rely on trial and error to make this work.  It is no reflection on him; I just wasn't able to get online for awhile.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36561270
pwdells,

You should post your own solution so that others reading the question know what you had to 'fix', if anything (you can mark your own answer as accepted and award points to cap's answer).

< It is no reflection on him...>

Also, fwiw - the grade given does affect the points that the Expert receives for helping you (the yes/no voting buttons, on the other hand do not).  Usually lower grades, which lower the points received, should only be given if you have given the Expert a fair chance to clarify or improve the solution.

0
 

Author Comment

by:pwdells
ID: 36561315
In the past, I have posted my code, in situations like this.  This time, I am unable, as this project was handed over to the next developer and I am taking on a new project this week.  My rights to read/write privilages to that folder are now revoked.  If I meet the new developer or get reassigned to this project, I will remember to do so.

0

Featured Post

Technology Partners: 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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

690 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