469,330 Members | 1,295 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

Clear out A table with VBA

ChaseCox
294 100+
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
5 29646
MSeda
159 Expert 100+
The following command will delete all records unconditionally from the table named UnitSize.

Docmd.runSQL "DELETE UnitSize.* FROM UnitSize;"
Mar 5 '07 #2
ChaseCox
294 100+
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
12,516 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. DoCmd.SetWarnings False
  2. DoCmd.RunSQL ...
  3. DoCmd.SetWarnings True
Mar 5 '07 #4
ChaseCox
294 100+
Thank you very much
Mar 5 '07 #5
Rabbit
12,516 Expert Mod 8TB
No problem.
Mar 5 '07 #6

Post your reply

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

Similar topics

8 posts views Thread by John Smith Jr. | last post: by
5 posts views Thread by Michael C via AccessMonster.com | last post: by
reply views Thread by latin & geek via DotNetMonster.com | last post: by
4 posts views Thread by ThePinkPanther | last post: by
19 posts views Thread by Krishanu Debnath | last post: by
7 posts views Thread by Andrus | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.