Button to clear all data in a record

G

Guest

Hello all, is it possible to have a button on a form that will clear all the
data previously entered into this record?

I have been deleting records from my database and thought that the next
record i created would automatically use the lowest available number
(Autonumber used with primary key)

This was not the case and so i was left with the activityID numbers missing
where i had deleted the record. Although this is not a major problem it looks
very unprofessional when scrolling through records to see the ID numbers
missing.

Any suggestions appreciated.
 
J

Joseph Meehan

Maax said:
Hello all, is it possible to have a button on a form that will clear
all the data previously entered into this record?

I have been deleting records from my database and thought that the
next record i created would automatically use the lowest available
number (Autonumber used with primary key)

This was not the case and so i was left with the activityID numbers
missing where i had deleted the record. Although this is not a major
problem it looks very unprofessional when scrolling through records
to see the ID numbers missing.

Any suggestions appreciated.

Assign the number in the BeforeUpdate event.

If Me.NewRecord Then

Me!NameOfField = Nz(DMax("YOURFIELDNAME","TABLENAME"), 0) + 1

End If

Replace the 0 if you want a different starting number


Note: I did not author the above instructions. I don't think I copied
them from the MS Access file so I post them with my apologies to the
original author. If these are your instructions and do don't wish me to
offer them or would like proper recognition, please let me know.
 
G

Guest

Hi Maax,

The autonumber behavior that you are witnessing is by design. To avoid any
confusion, you should set the visible property for a text box that is bound
to an autonumber data type to No, all all forms and reports. That way, your
user will never see the gaps.

An autonumber is intended to be a completely meaningless number. People get
confused when they attempt to assign any type of meaning to it at all, such
as a count of records.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 

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