B
Bruce
On several previous occasions I have posted a variant of
this question, and have received a variety of answers, but
am unfortunately as far away from a solution as I was
several days ago. If what I am trying to do is not
possible, please let me know, and I will stop asking.
I have a form (frmMain). It contains the text box
[txtFormID]. The table (tblMain) that underlies the form
contains the field [FormID]. [txtFormID] in frmMain has
as its record source [FormID] in tblMain. The first form
of the year is to be numbered (in [FormID]) 04-01, the
second 04-02, etc. 04 is the year. I don't care how it
gets there, but I would like the numbering to start
automatically with 05-01 next year.
My idea was to create a field [Increment] in tblMain, and
to have the value of [FormID] be (Year)&"-"&[Increment].
I got the idea that I could use DMax to increment the
number. I tried attaching to On Current:
If Me.NewRecord Then
Me.txtFormID = Nz(DMax("[Increment]", "tblRFImain"), 0)
+ 1
End If
as a means of incrementing a number (not bothering with
the 04- part of the number for now), but it did not work.
When I used the same formula except with [FormID] in place
of [Increment], it worked, and [txtFormID] showed 1, 2, 3,
etc. on successive records.
I have seen variants of this formula attached to Before
Update. That works, but I would prefer that the user see
the form number when a new form is started. I believe I
can attach something to the On Error event to increment
the number in case there are two users at the same time,
assuming that I can get it to work in the first place.
Also, I have seen variants with Me.txtFormID at the
beginning of the code, and other with Me![txtFormID].
Both seem to work. What's up with that?
Thanks in anticipation of good news, but failing that, any
news.
this question, and have received a variety of answers, but
am unfortunately as far away from a solution as I was
several days ago. If what I am trying to do is not
possible, please let me know, and I will stop asking.
I have a form (frmMain). It contains the text box
[txtFormID]. The table (tblMain) that underlies the form
contains the field [FormID]. [txtFormID] in frmMain has
as its record source [FormID] in tblMain. The first form
of the year is to be numbered (in [FormID]) 04-01, the
second 04-02, etc. 04 is the year. I don't care how it
gets there, but I would like the numbering to start
automatically with 05-01 next year.
My idea was to create a field [Increment] in tblMain, and
to have the value of [FormID] be (Year)&"-"&[Increment].
I got the idea that I could use DMax to increment the
number. I tried attaching to On Current:
If Me.NewRecord Then
Me.txtFormID = Nz(DMax("[Increment]", "tblRFImain"), 0)
+ 1
End If
as a means of incrementing a number (not bothering with
the 04- part of the number for now), but it did not work.
When I used the same formula except with [FormID] in place
of [Increment], it worked, and [txtFormID] showed 1, 2, 3,
etc. on successive records.
I have seen variants of this formula attached to Before
Update. That works, but I would prefer that the user see
the form number when a new form is started. I believe I
can attach something to the On Error event to increment
the number in case there are two users at the same time,
assuming that I can get it to work in the first place.
Also, I have seen variants with Me.txtFormID at the
beginning of the code, and other with Me![txtFormID].
Both seem to work. What's up with that?
Thanks in anticipation of good news, but failing that, any
news.