Set up a macro in Access

M

Melissa

I have been trying to set up a macro in Access 2003 tto automatically insert
a number. I don't wish to use the autonumber field for this as I need to
start at a specific number and increase from there.
 
G

Guest

hi
I did this once but used VB.
you could create a table to hold your number. 1 field, 1
record. small table.
to call the next number i had a "new" button that used
this code:
Private Sub NewRec()
On Error Resume Next
Me!txtControlNbr = DLookup
("Disc_NN.Disc_NxN", "Disc_NN", "")
Me!txtItemID.SetFocus
End Sub
i then wrote an update query that added 1 to the number in
the next number table WHEN the new record was excepted. i
used an unbound form.
this method is more or less the same way that Access
handles autonumber except that it is a little more
flexable and controlable.
 
S

Steve Schapel

Melissa,

By the way, you can have an AutoNumber start at a pre-specified number
if you like.

This is probably not a job for a macro. You can use the Default Value
property of your number field's control on the form, set to...
DMax("[YourNumberField]","YourTable")+1
 
J

J. Silva

Hello, I did that, but I obtained this message "The expression you entered
contains invalid syntax: you omitted an operan or operator, you entered an
invalid character or comma, or you entered text without surrounding it in
quotation marks".

Can you help me to understand what is the problem.

Thanks,
Joana.

"Steve Schapel" escreveu:
Melissa,

By the way, you can have an AutoNumber start at a pre-specified number
if you like.

This is probably not a job for a macro. You can use the Default Value
property of your number field's control on the form, set to...
DMax("[YourNumberField]","YourTable")+1

--
Steve Schapel, Microsoft Access MVP
I have been trying to set up a macro in Access 2003 tto automatically insert
a number. I don't wish to use the autonumber field for this as I need to
start at a specific number and increase from there.
 
S

Steve Schapel

Joana

It is difficult to know what your problem is without knowing more
specific details. But here's one idea... it appears you may be using a
non-English version of Access. If so, it could be that the function
argument delimiter is a ; rather than a , and if so, the example
expression would be...
DMax("[YourNumberField]";"YourTable")+1

Otherwise, please post back with the exact copy of the expression you
tried, and let us know where you are using it.

--
Steve Schapel, Microsoft Access MVP

J. Silva said:
Hello, I did that, but I obtained this message "The expression you entered
contains invalid syntax: you omitted an operan or operator, you entered an
invalid character or comma, or you entered text without surrounding it in
quotation marks".

Can you help me to understand what is the problem.

Thanks,
Joana.

"Steve Schapel" escreveu:

Melissa,

By the way, you can have an AutoNumber start at a pre-specified number
if you like.

This is probably not a job for a macro. You can use the Default Value
property of your number field's control on the form, set to...
DMax("[YourNumberField]","YourTable")+1
 

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