Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default User form with looping doesn't start at right place.

I have a user form that runs through a list of questions. At form initialize
it runs a couple of macros one of which is a looping Public statement Loop =
loop +1 kind of (I need this to keep track of some other things). When the
user clicks a start over button (sets Loop to 0) the form doesn't start with
the same question as it does when it initializes. What's going on?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default User form with looping doesn't start at right place.

Hi,
Seeing part of your code would be helpfull.

It could be that you don't unload the form before starting over which would
cause the Initialize sub not to be re-run.
When a form is displayed for the first time, the Initialize sub is run. Then
if you hide the form (Me.Hide) the form is still there but hidden; once you
do a Show again, the form shows up without running Initialize.
Instead, when hidding the form, do an unload. Next time you show it, the
Initialize sub will be run:
Private Sub cmdOK_Click()
'...
Unload Me
End Sub

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Rominall" wrote:

I have a user form that runs through a list of questions. At form initialize
it runs a couple of macros one of which is a looping Public statement Loop =
loop +1 kind of (I need this to keep track of some other things). When the
user clicks a start over button (sets Loop to 0) the form doesn't start with
the same question as it does when it initializes. What's going on?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default User form with looping doesn't start at right place.

I'm shortening some stuff but it should give you a good idea.
Initizialize userform application.run "Loop" & "Question"
'Question macro
'Get row based on Loop Num

RowResp = LoopNum
Range("A" + RowResp + "").Activate
Question = Activecell.value

'User form NEXTButton on click
Question.label = Question
Response.ControlSource = ("E" + RowResp +")

'User Form StartOverButton on click

LoopNum = 0

This is really the problem - when you click start over the QuestionLabel is
one row behind but the response goes to the correct row. Do I need to unload
and then reload the user form when the hit start over? Or do I need to put
the Question label in the initilize part? (I choose to put it in the button
click event because I wanted it hidden until they read a disclaimer and
clicked next - the question box is hidden until that point)

What would be the code?
I'm one of those people who knows enough to get myself in a lot of trouble
and not enough to get myself out of it.



"sebastienm" wrote:

Hi,
Seeing part of your code would be helpfull.

It could be that you don't unload the form before starting over which would
cause the Initialize sub not to be re-run.
When a form is displayed for the first time, the Initialize sub is run. Then
if you hide the form (Me.Hide) the form is still there but hidden; once you
do a Show again, the form shows up without running Initialize.
Instead, when hidding the form, do an unload. Next time you show it, the
Initialize sub will be run:
Private Sub cmdOK_Click()
'...
Unload Me
End Sub

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Rominall" wrote:

I have a user form that runs through a list of questions. At form initialize
it runs a couple of macros one of which is a looping Public statement Loop =
loop +1 kind of (I need this to keep track of some other things). When the
user clicks a start over button (sets Loop to 0) the form doesn't start with
the same question as it does when it initializes. What's going on?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
for Looping in VBA/Form Excel 2003 - SPB Excel Discussion (Misc queries) 4 July 24th 06 03:01 PM
How to auto place start/stop characters in Excel w/barcode fonts? Mel Excel Discussion (Misc queries) 1 May 12th 05 11:29 PM
How to: User Form to assign a user defined range to a macro variab TrevTrav Excel Programming 1 March 22nd 05 07:57 PM
Looping through controls on form Robbyn Excel Programming 2 March 15th 05 02:37 PM


All times are GMT +1. The time now is 05:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"