S
Slez via AccessMonster.com
I posted a question yesterday and got some very helpful advice, but have
never used this function and have a few additional questions. I have pasted
my original posting below for reference. I have the following expression
with the help I received yesterday, but am struggling with where to take it
from there.
=Nz(DMax("[PunchID]","tblPunchItems","[JobNumber]=' " & [Me].[txtJobNumber] &
" ' "),0)+1
I placed this in the Default Value property of the PunchID control. Is this
the correct location?...or is this supposed to be in one of the events?
In the help I received yesterday, it listed NewPunch in the beginning of the
expression. Am I supposed to name the control this, or create a new control?
Access added brackets around [Me].[txtJobNumber] automatically. Is this
affecting how the expression works?
I've tried altering the expression slightly. I get either of the following
messages in the new record no matter what I try: #Name? or #Error
As mentioned my original posting is pasted below. I really appreciate any
guidance on this!!
Slez
Original posting:
I am creating a form where users enter new records that relate to the field
[JobNumber]. I am wondering how to write an expression or code that will add
1 to the New Record in the field [PunchID]. It would be sort of like an
AutoNumber, but each JobNumber would start with "001". Here is an example:
JobNumber PunchID
065555 001
065555 002
065555 003
- new record would default to 004
065577 001
065577 002
- new record would default to 003
...and so on...
JobNumber is the one side of a one-to-many relationship with PunchID.
Thank you in advance for any help!
Klatuu responded:
NewPunch = Nz(DMax("[PunchID]", "MyTableName", "[JobNumber] = '" &
Me.txtJobNumber & "'"),0) + 1
never used this function and have a few additional questions. I have pasted
my original posting below for reference. I have the following expression
with the help I received yesterday, but am struggling with where to take it
from there.
=Nz(DMax("[PunchID]","tblPunchItems","[JobNumber]=' " & [Me].[txtJobNumber] &
" ' "),0)+1
I placed this in the Default Value property of the PunchID control. Is this
the correct location?...or is this supposed to be in one of the events?
In the help I received yesterday, it listed NewPunch in the beginning of the
expression. Am I supposed to name the control this, or create a new control?
Access added brackets around [Me].[txtJobNumber] automatically. Is this
affecting how the expression works?
I've tried altering the expression slightly. I get either of the following
messages in the new record no matter what I try: #Name? or #Error
As mentioned my original posting is pasted below. I really appreciate any
guidance on this!!
Slez
Original posting:
I am creating a form where users enter new records that relate to the field
[JobNumber]. I am wondering how to write an expression or code that will add
1 to the New Record in the field [PunchID]. It would be sort of like an
AutoNumber, but each JobNumber would start with "001". Here is an example:
JobNumber PunchID
065555 001
065555 002
065555 003
- new record would default to 004
065577 001
065577 002
- new record would default to 003
...and so on...
JobNumber is the one side of a one-to-many relationship with PunchID.
Thank you in advance for any help!
Klatuu responded:
NewPunch = Nz(DMax("[PunchID]", "MyTableName", "[JobNumber] = '" &
Me.txtJobNumber & "'"),0) + 1