Changing a Sub Procedure to a Function

  • Thread starter Thread starter KevinC
  • Start date Start date
K

KevinC

Hi everyone.

I have a very simple query (I think).

I have a form with text boxes for the opening and closing times of a
shop for each day of the week.

I am trying to speed up data entry, and as quite a number of the shops
we are dealing with are open 24 hours I thought that I would try to
automate some of the process. To do this I added a check box to the
form (next to each day) where the OnClick event of the check box sets
the corresponding days opening time to a value of "00:01" and the
closing time to "23:59" (this is how we represent 24 hour opening
where I work).

This all works fine as a Sub, however I then realised that I would
have to duplicate the code 7 times (for each day of the week).

I believe that it would be much better to convert the code so that it
is a function - however I don't know how to do this.

Can anyone guide me along here?

In addition it would also be useful to have another check box that
"Sets all days to 24 hours" - if anyone can give tips on this too I
would be most grateful.

Cheers

Kevin

P.S. Here is the sub routine:

Public Sub chkMon24Hrs_Click()
If Me!chkMon24Hrs.Value = True Then
Me!txtMON_OP.Value = "00:01"
Me!txtMON_CLO.Value = "23:59"
Else
Me!txtMON_OP.Value = Null
Me!txtMON_CLO.Value = Null
End If
End
 
Hi Dave,

Appologies for the cross posting. I thought it might have been ok as
the question was quite generic and I thought that it sat well in both
groups - and i am unaware of what users look at what groups. I was
just on my way over here to add a link to the resolved post.

Thanks for the head up on the best practice though.

And most of all thanks for supplying a solution on the other post!
(which is here:

http://groups.google.com/group/micr...1a2ab95ff3b/14f429dd7540dcc6#14f429dd7540dcc6
 
Back
Top