Rob:
My guess would be that the Transaction_Number field is the wrong data type,
so, if I'm right, it would need changing. For a number data type use a long
integer, though as the number is essentially a 'code' rather than a numeric
value per se a Text data type might be more appropriate. However, once
you've corrected that, you can assign a value more simply with the Format
function:
Me.Transaction_Number = Format(Now(),"mdyyyys") & Me.cmbCustomer.Column(2)
If you want leading zeros either use "mmddyyyyss" and a Text data type for
the field rather than a number, or "mddyyyyss" with a long integer or text
data type and set the fields' Format property to 0000000000.
Ken Sheridan
Stafford, England
Rob said:
Ken,
I tried that. But I keep getting a run-time error that states "The value
you entered isn't valid for this field". I am trying to place information in
a number field called Transaction Number. my line of code looks like this:
Me.Transaction_Number = DatePart("m", Now) & DatePart("d", Now) &
DatePart("yyyy", Now) & DatePart("s", Now) & Me.cmbCustomer.Column(2)
Everything works until I add the seconds. Do I need to convert the seconds
to value before using it? I think that I tried Val(DatePart("s",Now). That
gave me the same error.
Ken Sheridan said:
Rob:
Yes, use "s" as the interval argument:
DatePart("s",[MyDateTimeField])
That will give you just the seconds part of the date/time value, e.g. for 30
April 2008 23:06:12 it would return 12. Is that what you want?
Ken Sheridan
Stafford, England
:
Scott,
Is there a way to get the seconds using DatePart?
Thanks,
Rob
:
You can use the DatePart function to get the minutes as well:
DatePart('n',[MyDateTimeField])
Search on DatePart in MS Access Help for additional details
:
Hi,
I'm running a query and have a field containing the date and time. I'd like
the query to extract the Hours and Minutes from this field. I've used the
DatePart function to get the hour, but can't seem to get the minutes.
Thanks
SquirrelToothAnnie