Quite similar to what I suggested yesterday. I'm not sure of the exact
limitations of what functions can be used in the Default Value in a table,
but I don't think any domain aggregate functions can be used.
"Paul Shapiro" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> John's code below should work for assigning the sequence number in your
> present scheme. A better design would be to split the sequence number and
> the year into two fields. Data fields should be atomic, without any
> meaning to sub-sections of the field. So a long integer year field, with a
> meaningful name like orderYear or meetingYear or whatever it is (since
> 'year' is a reserved word and should not be used as a field name) and a
> second long integer for annualSequenceNumber. That avoids the issue John
> mentioned of being limited to 99 rows per year and programming against the
> data is clearer because the data is simpler. You can use an expression (in
> a query, form or report) to display your current ID:
> OriginalID = Format([annualSequenceNumber], "00") & "/" & [orderYear]
>
> To get the next data values, you could use code like this:
> Dim thisYear as Long
> Dim seqNumNext as Long
> Dim strWhere as string
>
> thisYear = Year(Date())
> strWhere = "[orderYear]=" & thisYear
> seqNumNext = 1 + nz(dMax("[annualSequenceNumber]", "[tablename]",
> strWhere), 0)
>
> In the table design mode you could set the default value for orderYear to
> be Year(Date()), so that would automatically be entered with the correct
> value. I don't think you can use the expression for seqNumNext as a
> default value, but you could try a variation like this and see if it
> works:
> 1 + nz(dMax("[annualSequenceNumber]", "[tablename]", "[orderYear]=" &
> Year(Date())), 0)
>
>
> "Jon" <(E-Mail Removed)> wrote in message
> news:EC604C19-F0CF-4F52-96CE-(E-Mail Removed)...
>> Hi,
>> 01 & 02 are not a date, they are a sequence number? Please advice???
>>
>>
>> "Paul Shapiro" wrote:
>>
>>> "Custom" and "Auto" are mutually exclusive. You can write code to assign
>>> a
>>> default value to the textbox each time a new record is added to a form.
>>> You
>>> might consider whether storing what appears to be a date as a text field
>>> is
>>> a good idea. If you want the default value for this field to be the
>>> first
>>> day of the current month, you could set a default value in the table
>>> design
>>> mode: DateSerial(year(date()), month(date()), 1).
>>>
>>> "Jon" <(E-Mail Removed)> wrote in message
>>> news:9DBA4177-0AE0-45CA-88E8-(E-Mail Removed)...
>>> >I have text box "ID" and it is text and I would like to custom it to be
>>> >auto
>>> > number as the following format:
>>> > 01/2009
>>> > 02/2009
>>> > ....
>>> > and so on.
>>> >
>>> > How to do that???
>
|