Set up a macro in Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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.
 
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
 
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.
 
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
 
Back
Top