Date serial number

G

Gib

Hello to all.

I am trying get the default value of a field to be date
and time but in a number (serial?) format. This is to be
done in a Private Sub when opened. I have tried
MyValue=Date() and DateSerial() but can't seem to get it
to work.

Any sugestions are welcome.

Thanks
Gib
 
K

Ken Snell

Define "serial format" and then I'm sure it can be done....probably using
the Format function.
 
A

Allen Browne

Use the BeforeInsert event of the form to create the string of numbers
representing the text you want. Something like this:

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.[YourSerialNumber] = Format(Now(), "yyyymmddhhnnss")
End Sub

The BeforeInsert event fires at the moment you begin adding a new record, so
it will receive its value at that moment.
 
G

Gib

That did it.

Thanks
-----Original Message-----
Use the BeforeInsert event of the form to create the string of numbers
representing the text you want. Something like this:

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.[YourSerialNumber] = Format(Now (), "yyyymmddhhnnss")
End Sub

The BeforeInsert event fires at the moment you begin adding a new record, so
it will receive its value at that moment.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I am trying get the default value of a field to be date
and time but in a number (serial?) format. This is to be
done in a Private Sub when opened. I have tried
MyValue=Date() and DateSerial() but can't seem to get it
to work.

Any sugestions are welcome.

Thanks
Gib


.
 

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