concatenate date/time with autonumber

S

ssmookherji

hi all,
i am preparing a software where i need to concatenate date/time (now
()) with a auto number field. for example: if the date is 20/04/2009
16:24:20 and the auto number is 2012 then it should show as
200420091624202012. i have successfully converted the date and time as
20042009162420 but when ever i am concatenating the auto number it is
getting converted as value. i wil really appriceate if some one can
help me on it as urgent....(i am very new and have very little
knowledge so if you need any more clearity please mark a mail to me at
(e-mail address removed))
thanks
shanki
 
L

Linq Adams via AccessMonster.com

when ever i am concatenating the auto number it is
getting converted as value.

Not really sure what this means, but an autonumber isn't written to the table
until the record is committed to the table, so you need to grab the maximum
autonumber then add one to it. Since you converted the Date/Time to a string,
this should work, where YourConvertedDateTime is this converted date and [ID]
is the autonumber:

Private Sub Form_Current()
If Me.NewRecord Then
Me.CombinedField = YourConvertedDateTime & CStr(DMax("[ID]", "YourTable") +
1)
End If
End Sub
 
K

Keith Wilby

hi all,
i am preparing a software where i need to concatenate date/time (now
()) with a auto number field. for example: if the date is 20/04/2009
16:24:20 and the auto number is 2012 then it should show as
200420091624202012. i have successfully converted the date and time as
20042009162420 but when ever i am concatenating the auto number it is
getting converted as value. i wil really appriceate if some one can
help me on it as urgent....(i am very new and have very little
knowledge so if you need any more clearity please mark a mail to me at
(e-mail address removed))
thanks
shanki

Why do you need to do this? An AutoNumber data type if for internal
indexing purposes and its value meaningless to the user.

Keith.
www.keithwilby.co.uk
 
J

John W. Vinson

hi all,
i am preparing a software where i need to concatenate date/time (now
()) with a auto number field. for example: if the date is 20/04/2009
16:24:20 and the auto number is 2012 then it should show as
200420091624202012. i have successfully converted the date and time as
20042009162420 but when ever i am concatenating the auto number it is
getting converted as value. i wil really appriceate if some one can
help me on it as urgent....(i am very new and have very little
knowledge so if you need any more clearity please mark a mail to me at
(e-mail address removed))
thanks
shanki

Well... no. You really DON'T need to do this, certainly not if you're
intending to store the value in the table. Dates are *data*; an Autonumber is
already unique, and appending a date won't make any "uniquer".

What real-life problem are you trying to solve? What will you do with this
string once you create it?
 

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