sequential numbers in an access database

G

Guest

i am not a programmer. i am not smart. i need a simple, step by step
explantion of how to make a field in a database record and display and print
a sequential number for each record in a database. i looked thru previous
posts, but they were all written and answered by programmers or people much
smarter than i am and i could not understand the questions or the answers. i
was using the autonumber function, but i deleted a couple of records and now
the numbers are not sequential. another post said i should use something
called a long integer, but i don't understand what that is or how to use it.
someone please have mercy on an idiot.
 
G

Guest

sorry fred, not smart enough to follow this example. tried to enter it
several different ways in the table, but kept getting syntax errors and wrong
number of operators errors and such. i am a paclid; a moron; a simpleton; i
need small words, spoken very slowly. thank you for trying anyway.
ntb
 
R

Rick Brandt

not_that_bright said:
sorry fred, not smart enough to follow this example. tried to enter it
several different ways in the table, but kept getting syntax errors
and wrong number of operators errors and such. i am a paclid; a
moron; a simpleton; i need small words, spoken very slowly. thank you
for trying anyway.
ntb

You can't do this at the table level. It must be done with code in the form
used for entering records.

Let's say the field you want to increment is named ID. In form design view you
would find the BeforeUpdate event property on the Events tab of the property
sheet. Make sure the property sheet is displaying properties for the form and
not an object on the form by pressing the small gray square in the upper left of
the form window.

In the BeforeUpdate event property choose "[Event Procedure]" from the list of
choices and then press the build button [...] to the right of the property.

You should now be in the VBA code editor window positioned between the two
pre-made lines shown below...

Private Sub Form_BeforeUpdate(Cancel As Integer)

End Sub


Between those two lines add...

If IsNull(Me![ID]) = True Then
Me![ID] = Nz(DMax("ID", "YourTableName"), 0) + 1
End If

For the above to work you should not have any default value assinged to the [ID]
field at the table level or in the form.

When you use the form to enter new records it should assign each new record the
next highest unused numeric value when the record is saved for the first time.
 
F

Fred Boer

Dear "trying to learn":

Ok. Stop flagellating yourself! <g> No need to put yourself down. Access is
not a simple program, and it takes some time to learn. Rick's given you some
good instructions. Give it a try, and post back if you need more help!

Cheers!
Fred
 
J

John Vinson

i need a simple, step by step
explantion of how to make a field in a database record and display and print
a sequential number for each record in a database.

If you just want to PRINT a sequential number... forget about trying
to store it in a table.

Instead, create a Report based on your table.

Put a textbox on the Report where you want the sequential number.

View its Properties in report design view.

Set its Control Source property to 1 - just the number one.

Set its Running Sum property to "Over All".

Print the report...

John W. Vinson[MVP]
 

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