auto numbering of a kind

M

MalcR

Is there a series of commands that can be placed in a macro to allow me to
resolve the following:-

My table “Tbl_Location†has three fields Phase, Section and DrawingNo among
others. I wish to record new numbers in the DrawingNo field, when a new
Section record is added using the conditions, that if it’s within an existing
Phase then assign the next available sequential number or reset to 1 if it is
a new Phase value that has been added.

Thanks Malc
 
S

Steve Schapel

Malc,

You can use a SetValue action in your macro, with these arguments:
Item: [DrawingNo]
Expression: Nz(DMax("[DrawingNo]","Tbl_Location","[Phase]='" & [Phase]
& "'"),0)+1
(assumes Phase is Text data type)

You could possible assign this macro on the After Update event property
of the Phase or Section controls on the form, and you will probably want
a Condition on the macro like this...
[DrawingNo] Is Null And [Phase] Is Not Null
 
M

MalcR via AccessMonster.com

Steve,

Thanks for taking the time out to reply, but I keep getting the "action
failed" message.

I copied and pasted the expression below after changing the field type for
[Phase] to text. I then changed it back to number type and used one of your
earlier tips namely; Nz(DMax("[DrawingNo]","Tbl_Location","[Phase]='" &
[Phase] ),0)+1 still no luck.

As you may have realised I'm new to macros, is there something fundamental
that I'm missing?




Steve said:
Malc,

You can use a SetValue action in your macro, with these arguments:
Item: [DrawingNo]
Expression: Nz(DMax("[DrawingNo]","Tbl_Location","[Phase]='" & [Phase]
& "'"),0)+1
(assumes Phase is Text data type)

You could possible assign this macro on the After Update event property
of the Phase or Section controls on the form, and you will probably want
a Condition on the macro like this...
[DrawingNo] Is Null And [Phase] Is Not Null
Is there a series of commands that can be placed in a macro to allow me to
resolve the following:-
[quoted text clipped - 6 lines]
Thanks Malc
 
M

MalcR via AccessMonster.com

MalcR said:
Steve,

Thanks for taking the time out to reply, but I keep getting the "action
failed" message.

I copied and pasted the expression below after changing the field type for
[Phase] to text. I then changed it back to number type and used one of your
earlier tips namely; Nz(DMax("[DrawingNo]","Tbl_Location","[Phase]='" &
[Phase] ),0)+1 still no luck.

As you may have realised I'm new to macros, is there something fundamental
that I'm missing?
[quoted text clipped - 14 lines]

Steve,

Now working fine, my mistake. Thanks very much for your help
 

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