Unexpected Deletion of Table

G

Guest

When I click the up/down scroll buttons or scroll bar it often, but not
always, reacts as if I am closing the form and deletes the table rows
prematurely. The form has a close event procedure and uses ADO to delete the
table rows, which works correctly. Does anyone know why the scroll
buttons/bar will invoke the close event procedure and how to stop unintended
table row deletion?

Specifics: I built a form and programmed a table for the local food bank to
help them forcast how many volunteers will be present at a given time on a
given day so they do not book too many volunteers for any time period. The
data source table contains the date, arrival time, departure time and number
of volunteers expected for each group. Using a command button click event
procedure, I read this table, use the hour and minute functions to help
populate an array(25,60) to accumulate the number of volunteers present at
any given 30 minute period from 8AM to 7:30PM for the next 60 days, one date
per row. Since noone could help me address array items within the procedure
directly, I finally used ADO to write a table from that array showing the
accumulated number of volunteers present per day and period. Then I built and
displayed a form in datasheet view from that table in date order. I used ADO
in the form close event procedure to delete the table rows.

Dim objConn As New ADODB.Connection
Dim rsForcast As New ADODB.Recordset
Dim SQLStmt As String
SQLStmt= ""
SQLStmt= "Delete * From tblScheduled Where tblScheduled.dtmDate > (Now()-1);"
CurrentProject.Connection.Execute SQLStmt

What am I doing wrong, or what do I need to change?
 
M

Mark A. Sam

Welcome to the world of Microsoft. ;)

I don't have a clue why some things happen on my databases, but a suggestion
for you would be to delete the table when you open using the Open or Load
events, rather than the close event.

I won't promise that Access won't figure a way to "open" the database
unexpectedly, but so far I haven't seen it. ;)

God Bless,

Mark A. Sam
 
G

Guest

Both the load and open events delete the contents of the table before it is
displayed. I am going to try making the array a public variable to see if I
can address it while opening the form, skirting the table row creation
entirely. I will let you know whether this works.
 

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