By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Clear out A table with VBA

ChaseCox
100+
P: 294
I would like to clear out all the records of a table using VB Code. I am building the table on the fly, so that I can cross reference it with my main table. The table consits of a multiple 3 digit numbers, depending on the check box the user clicks.

The DB name is FalconAnalysis, the table name is UnitSize and the only field in the table is Size. Here is the Code I am using, the first builds my array based on the check boxes, and the second part passes the values into my table as long as they are not zero.
Expand|Select|Wrap|Line Numbers
  1. Private Sub MakeFilter2()
  2.  
  3.     If Nz(chkv2125S, False) Then _
  4.             SizeArray(0) = 150
  5.     If Nz(chkv2125H, False) Then _
  6.             SizeArray(1) = 151
  7.     If Nz(chkv215S, False) Then _
  8.             SizeArray(2) = 180
  9.     If Nz(chkv215H, False) Then _
  10.             SizeArray(3) = 181
  11.     If Nz(chkv2175S, False) Then _
  12.             SizeArray(4) = 210
  13.     If Nz(chkv2175H, False) Then _
  14.             SizeArray(5) = 211
  15.     If Nz(chkv220S, False) Then _
  16.             SizeArray(6) = 240
  17.     If Nz(chkv220H, False) Then _
  18.             SizeArray(7) = 241
  19.     If Nz(chkv225S, False) Then _
  20.             SizeArray(8) = 300
  21.     If Nz(chkv225H, False) Then _
  22.             SizeArray(9) = 301
  23.  
  24.     End Sub
  25.  
  26.  Private Sub boxxob_Click()
  27.      Dim intI As Integer
  28.  
  29.      For intI = 0 To 9
  30.         Dim FalconAnalysis As Object
  31.         Dim tblUnitSize As Object
  32.         Dim colSize As Object
  33.         Set FalconAnalysis = CurrentDb
  34.         Dim UnitSize As Recordset
  35.         Set UnitSize = FalconAnalysis.OpenRecordset("UnitSize", dbOpenTable)
  36.         Dim strStringArray()
  37.         If SizeArray(intI) = 0 Then
  38.         Else
  39.         UnitSize.AddNew
  40.         UnitSize.Fields(0).Value = SizeArray(intI)
  41.         UnitSize.Update
  42.         UnitSize.Close
  43.           End If
  44.      Next
  45.  
  46.  
  47. End Sub
  48.  
If this is possible, or not, please let me know. I have been trying to use the Delete comand with no success. Thanks for the help.
Mar 5 '07 #1
Share this Question
Share on Google+
5 Replies


MSeda
Expert 100+
P: 159
The following command will delete all records unconditionally from the table named UnitSize.

Docmd.runSQL "DELETE UnitSize.* FROM UnitSize;"
Mar 5 '07 #2

ChaseCox
100+
P: 294
The following command will delete all records unconditionally from the table named UnitSize.

Docmd.runSQL "DELETE UnitSize.* FROM UnitSize;"

Thanks! is there a way to not have the warning about deleting the records from showing up.

CHEERS!!!!
Mar 5 '07 #3

Rabbit
Expert Mod 10K+
P: 12,366
Expand|Select|Wrap|Line Numbers
  1. DoCmd.SetWarnings False
  2. DoCmd.RunSQL ...
  3. DoCmd.SetWarnings True
Mar 5 '07 #4

ChaseCox
100+
P: 294
Thank you very much
Mar 5 '07 #5

Rabbit
Expert Mod 10K+
P: 12,366
No problem.
Mar 5 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.