Newbie needs assistance

F

Fuzzy Logic

I have a table with 2 fields the first a number and the second text. It has
data like:

1 one
2 two
3 three
4 four
etc.

I have created a form which displays one record at a time and has a delete
button on it. When I push the delete button I want to delete the currently
displayed record (say record 2) and get this result:

1 one
2 three
3 four
4 five
etc.

Essentially deleting record 2 decrements the first field by 1 for all
records with a number higher than the number of the record deleted.

I have tried various methods to do this and haven't had any success. Can
someone either supply code or send me some pointers to where I can figure
this out. If you want to send me a MDB file that's fine (just zip it up as
our mail server will strip it otherwise). A big thanks to anyone who can
help me out! I appear to have hit a wall and don't know how to proceed.
 
G

George Nicholson

You'll need to write some code.

1) before you delete the record, capture the value of NumField for that
record in a variable (intNum).
2) delete the record
2) run an update query on the table:
UPDATE MyTable SET MyTable.NumField = [NumField]-1 WHERE
(((MyTable.NumField) > intNum));
 
F

Fuzzy Logic

You'll need to write some code.

1) before you delete the record, capture the value of NumField for that
record in a variable (intNum).
2) delete the record
2) run an update query on the table:
UPDATE MyTable SET MyTable.NumField = [NumField]-1 WHERE
(((MyTable.NumField) > intNum));

I figured I needed to write some code and have something similar to this
but where does this code actually go? I have been putting it in the Build
Event properties for the delete button in the Form Design View. Is that
the correct place?
 

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