Date serial number

  • Thread starter Thread starter Gib
  • Start date Start date
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
 
Define "serial format" and then I'm sure it can be done....probably using
the Format function.
 
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.
 
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


.
 
Back
Top