VBA - MSWORD2007 - LessonPlan AutoWizard Template - Period Selecti

C

Carl

G'day all,

I am on teaching placement at the moment, and have found some time to do a
little bit of VBA coding. I am creating an AutoWizard in MSWord to create a
lesson plan for me, so i dont have to worry about formatting. (Makes things
quicker).

My current issue is as follows;

I have 8 period checkboxes, (currently not arrayed).
When a period selected I need it to recognise a text box
value(txt_starttime) find out if the period starts before or after
txt_starttime.value
*If the period starts after the already existing start time then exit sub
*If the period starts before the already existing start time then
txt_starttime needs to be updated by this.

<<VARIABLES/OBJECTS>>
*var_period1start - variable for user entered start time
*form_txtbox_starttime - Textbox Object on form, needs to be read and on
condition updated

<<Current Code>>
(Per checkbox - Will probably be arraying in future Version)

Dim var_period1start as integer

Private Sub form_chkbox_period1_Click()
If var_period1start > form_txtbox_starttime.Value Then
form_txtbox_starttime.Value = var_period1start
End If
End Sub

<<End of Code>>

Any tips, suggestions or solutions would be a great help :)

Thankyou in advance,

Carl
 
J

Jean-Guy Marcil

Carl was telling us:
Carl nous racontait que :
G'day all,

I am on teaching placement at the moment, and have found some time to
do a little bit of VBA coding. I am creating an AutoWizard in MSWord
to create a lesson plan for me, so i dont have to worry about
formatting. (Makes things quicker).

My current issue is as follows;

I have 8 period checkboxes, (currently not arrayed).
When a period selected I need it to recognise a text box
value(txt_starttime) find out if the period starts before or after
txt_starttime.value
*If the period starts after the already existing start time then exit
sub
*If the period starts before the already existing start time then
txt_starttime needs to be updated by this.

<<VARIABLES/OBJECTS>>
*var_period1start - variable for user entered start time
*form_txtbox_starttime - Textbox Object on form, needs to be read and
on condition updated

<<Current Code>>
(Per checkbox - Will probably be arraying in future Version)

Dim var_period1start as integer

Private Sub form_chkbox_period1_Click()
If var_period1start > form_txtbox_starttime.Value Then
form_txtbox_starttime.Value = var_period1start
End If
End Sub

<<End of Code>>

Any tips, suggestions or solutions would be a great help :)

I kind of guess what you want to do, however, I am not sure what the actual
problem is.
What difficulty are you facing, exactly?
What are the observed behaviours versus the expected ones?

For now, I can tell that you might have problems with:
var_period1start > form_txtbox_starttime.Value
because you are comparing an Integer to a String.

Also, because of the different types, it would be better to use:
form_txtbox_starttime.Value = CStr(var_period1start)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top