form headers

E

Eloy

I am trying to create an attendance (school teacher) form. I would like to
input the date in the form header and view the records in a continuous form
format. Problem, when I input the date in an unbound text box, I lose the
data. If is use a field such as "Date1", then that info disappears when I
select another record. Is there a method where I can input a date in the
form header and not lose the data?
eloy
 
D

Dennis

Eloy,

I'm new to access, but I have solved this problem with other variable types,
but not with a date. Have you tried putting the value in a "private
variable" that is declared at the form level? At the very top of you form's
VBA code - after the following statements:

Option Compare Database
Option Explicit

‘Declare Private variable

Private dblMyDate as Double


Since dates are stored as an 8 byte decimal number, I am guessing you will
need to declare your variable as a double variable, but I'm not sure. I'm
sure someone else will correct me.

Provided you delcare the private variable in the declarationi section of
your form's module, you will be able to use dblMyDate in any procedure within
that module.

So you could set it based upon the value that was initially entered. For
the purpose of this discussion, we'll say you have the user enter the date in
a text box call txtUserDt. In the After Update event of the txtUserDt put:

lngMyDate = txtUserDt

Also, if you want the correct date to appear in the form when you navigate
your records, you will need to put the following in the Form's Current Event:

txtUserDt = lngMyDate


The only part I don't know is how the date will be handle going between a
double floating point number and a text field. You may have to use the
Format function to get the right date formatted. You can see the Format
Function in the VB code window's help function.

I hope this helped. I know this is the blind leading the blind, but
everyone has been so helpful to me I felt I should try to return the help.

Good luck


Dennis
 
E

eloy

Thanks for your help, Dennis!
I am not a programmer by any stretch, but I carefully followed your
instructions. For some reason, it doesn't like what I entered in the forms
"On Current". It tells me that "the object doesn't contain the automation
object IngMyDate". I sure would appreciate a follow-up. Thanks again.

eloy
 

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