Generic Sub

K

Keith Emery

I need a generic Sub() that I can call from various forms
to take user entered dates and convert then into true long
date/time values. So far I have had to copy code fromo one
form to the next.

********************************************************
Sub UpdateHiddenDates(FormSelected As Form, Date1 As Date,
Date2 As Date, cntDate1 As Control, cntDate2 As Control)

FormSelected.cntDate1.Value = CDate(Date1 & " 00:00:00")
FormSelected.cntDate2.Value = CDate(Date2 & " 23:59:59")

FormSelected.Refresh
End Sub
*********************************************************

This does not work as i am using incorrect type values,
but don't know where they are wrong!
 
D

Douglas J. Steele

How are you calling the routine? If cntDate1 and cntDate2 are references to
controls, you don't need the FormSelected. in front of them: the reference
will be unambiguous.

Just to quibble, if Date1 and Date2 are already dates, I'd use
DateValue(Date1) and DateValue(Date2) + TimeSerial(23, 59, 59) instead of
what you've got.
 

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