Read Only Forms

J

John

Hello.

I have a form that I designed within Microsoft Access. I use the form
to import data into from Excel, and then print all that data out
within the design of the form.

I do not want the data to remain there however. I want it to all be
erased when I close Access. The reason is because I only ever need to
print out this data once, and I would like it to be empty for the next
time I need to import different data to print out.

How can I set the Access Database up so that I can import into it, but
the data won't remain there? Is it simply a matter of setting it up as
a read-only file?

Thanks for your help

John
 
S

Steve Schapel

John,

I assume the data from Excel is being imported into a table in your
Access database. You can't really import into a form... forms don't
have data, they simply display it, but the data itself is ultimately
stored somewhere else, normally a table. So, you could delete the data
from the table after you have finished with it. One way to do this
would be to use a VBA procedure on the Close event of the form,
something like this...
CurrentDb.Execute "DELETE * FROM YourTable"
 
J

John

John,

I assume the data from Excel is being imported into a table in your
Access database. You can't really import into a form... forms don't
have data, they simply display it, but the data itself is ultimately
stored somewhere else, normally a table. So, you could delete the data
from the table after you have finished with it. One way to do this
would be to use a VBA procedure on the Close event of the form,
something like this...
CurrentDb.Execute "DELETE * FROM YourTable"

Yes. The data is imported and stored in the table, but I display it
and print it in the form.

How do I set up the VBA procedure in Access? I only have a little
knowledge of Macros in Excel, but nothing like this that would delete
data before you click the close button.

Thanks

John
 
S

Steve Schapel

In design view of the form, look at the Properties of the form. One of
them is called On Close. In there, enter Event Procedure, and then
click the little ellipsis (...) button on the right. This will open the
VB Editor window, with something that looks like this...
Private Sub Form_Close()

End Sub

Just type the line of code I gave you in the space in the middle,
replacing YourTable with the actual name of the table you have the
imported data in. Close the VB Editor and close and save the form.
 
Top