A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Date serial number



 
 
Thread Tools Display Modes
  #1  
Old May 28th, 2004, 12:52 AM
Gib
external usenet poster
 
Posts: n/a
Default Date serial number

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
  #2  
Old May 28th, 2004, 02:49 AM
Ken Snell
external usenet poster
 
Posts: n/a
Default Date serial number

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

--
Ken Snell
MS ACCESS MVP

"Gib" wrote in message
...
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



  #3  
Old May 28th, 2004, 03:51 AM
Allen Browne
external usenet poster
 
Posts: n/a
Default Date serial number

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.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Gib" wrote in message
...

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



  #4  
Old May 28th, 2004, 12:05 PM
Gib
external usenet poster
 
Posts: n/a
Default Date serial number

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.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Gib" wrote in

message
...

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



.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:14 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.