ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   button reuser on forms (https://www.excelbanter.com/excel-programming/326624-button-reuser-forms.html)

Jabba

button reuser on forms
 
2nd post but can't see my first one from yesterday so.....

I am using a form to prompt the user with a series of questions (one at a
time!) with cmd buttons for 'true' and 'false'

The public sub for the 'true' button includes:
--------------------------------------------------------
x = x + 1 'offest count

Call next_question
--------------------------------------------------------

and next_question is in module1:

--------------------------------------------------------
form.Caption = "Question " & x
q = ActiveCell.Offset(x, 0).Text

form!question.Caption = q
form!Label1.Caption = x 'variable increment test
---------------------------------------------------------

Trouble is x does not increment more than once!
I've tried just having the incrementing code in the form code, in a separate
sub and in with the cmd true click event sub but nothing seems to work.

I've got 80 questions to go on this so I don't fancy 80 forms!

Any help would be appreciated

J

--
Jabba

K Dales[_2_]

button reuser on forms
 
Question: How (where) are you defining x? Is it in the Sub for the button,
or is it a global variable? It is hard to tell what is happening without
seeing more of your code. I suspect that either you are using a local
variable that keeps getting reset when you run your code, or else somewhere
else in your code you are inadvertently resetting the value of x. Can't say,
though, without seeing the whole thing.

"Jabba" wrote:

2nd post but can't see my first one from yesterday so.....

I am using a form to prompt the user with a series of questions (one at a
time!) with cmd buttons for 'true' and 'false'

The public sub for the 'true' button includes:
--------------------------------------------------------
x = x + 1 'offest count

Call next_question
--------------------------------------------------------

and next_question is in module1:

--------------------------------------------------------
form.Caption = "Question " & x
q = ActiveCell.Offset(x, 0).Text

form!question.Caption = q
form!Label1.Caption = x 'variable increment test
---------------------------------------------------------

Trouble is x does not increment more than once!
I've tried just having the incrementing code in the form code, in a separate
sub and in with the cmd true click event sub but nothing seems to work.

I've got 80 questions to go on this so I don't fancy 80 forms!

Any help would be appreciated

J

--
Jabba



All times are GMT +1. The time now is 08:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com