Weird attachment field behavior

D

Dave C

I have a table that is behaving strangely.

I use an attachment field to store a photograph of the person in the record.
On the input form, I have this field disabled and locked, and use a button
to programatically add the photo to the record. This works fine.

The weird behavior comes into play when I use a SQL statement to clear the
table. (I do this to clear my test data before distributing the database.)

The command is:

docmd.runsql "DELETE FROM tblGuests"

When I look, the table appears to be empty. However, when I call the form
to add a new record, as soon as I type something in the first field, the
picture that had been in the first record suddenly appears.

The same thing happens if I type a new record directly into the table. As
soon as the record goes dirty, I'll see the attachment field has changed from
0 to 1.

Is it necessary to go through the records one at a time and delete all
attachments before deleting the records, or is there an easier way to do it?
 
D

Dave C

Thanks for the trip, but that's not it. Both your code and mine operate the
same. The problem is still there.
 
G

Gina Whipp

Well, I just tested it and it appears to work fine so my next question is do
you have that table related to any other tables and not set as Cascading
Deletes that would cause some of the records not to be deleted?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
D

Dirk Goldgar

Dave C said:
I have a table that is behaving strangely.

I use an attachment field to store a photograph of the person in the
record.
On the input form, I have this field disabled and locked, and use a button
to programatically add the photo to the record. This works fine.

The weird behavior comes into play when I use a SQL statement to clear the
table. (I do this to clear my test data before distributing the
database.)

The command is:

docmd.runsql "DELETE FROM tblGuests"

When I look, the table appears to be empty. However, when I call the form
to add a new record, as soon as I type something in the first field, the
picture that had been in the first record suddenly appears.

The same thing happens if I type a new record directly into the table. As
soon as the record goes dirty, I'll see the attachment field has changed
from
0 to 1.

Is it necessary to go through the records one at a time and delete all
attachments before deleting the records, or is there an easier way to do
it?


I haven't worked with attachment fields in A2007 yet, but I wonder -- does
your attachment field have a Default Value?
 

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