Using modules to reset data

dallnsn

Registered User.
Local time
Tomorrow, 05:43
Joined
Aug 21, 2008
Messages
10
Hi Everyone,

I have a small problem, I have to design an access application using VBA. All tables have been given to me, and a module that once clicked, will reset all table data back to its original state as a means of testing.

My rather simple question is in VBA how do I utilise this module to reset the data in my tables. I have got a button Named Reset Data, and am trying to build an event in the "on click". I have tried DoCmd. , RunCommand but am coming up blank.

Any help is greatly appreciated.


dallnsn
 
Here is the code to delete all of a table's records.


Code:
 Dim recset As Recordset
 Set recset = CurrentDb.OpenRecordset("TableName", dbOpenTable)
 
 With recset
     ' Delete existing records
   Do While Not .EOF
     .Delete
     .MoveNext
   Loop
 End With


-dK
 
Thanks for the reply. I have a module that will wipe all existing data, and re-populate the tables with data. What I want to know, is how do I use the On click event to call the Reset Data Module, run it from the command button placed on my form.

If that makes any sense.
 
Just type the name of the function or sub in your click event code.

Private Sub ButtonClick()
FunctionNameHere
End Sub
 

Users who are viewing this thread

Back
Top Bottom