473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 30466
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

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

Similar topics

2
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to keep my numbers for transactions sequential. I clear my monthly transactions each month and store them in a general transactions...
8
by: John Smith Jr. | last post by:
I am looking for some way to persist a table web control so when page_load event comes up, i can display the table as it was. I tried using ViewState with the rows collection but that didn't work...
21
by: StriderBob | last post by:
Situation : FormX is mdi child form containing 2 ListViews ListView1 contains a list of table names and 4 sub items with data about each table. ListView2 contains a list of the columns on each...
5
by: Michael C via AccessMonster.com | last post by:
Hello, I have a table that I am appending 3 seperate tables into. My main problem is that each time I append the data, it simply adds to the data already there. That might sound ok, except that...
0
by: latin & geek via DotNetMonster.com | last post by:
hi! ok, im working on a database application. ive successfully managed to establish a relationship between two tables and display them on a datagrid, edit and add new records to them. now i...
4
by: ThePinkPanther | last post by:
Hello I seem to have a re-occuring problem with tables. Every tiime i create a new table in my code (Table x = new Table();) it creates in the final code the browser gets the attribute...
4
by: G .Net | last post by:
Hi I have a DataSet with several DataTables. I have set up relations between these tables. I want to delete all the tables and re-fill them. However, when I try to do so, even after using...
19
by: Krishanu Debnath | last post by:
Hello, I have a call to hash_map::clear() function which takes long time. someClass::someFunction() { // typedef hash_map<name_id, uintMp; // Mp p; // assuming proper namespace, hash...
2
by: harini | last post by:
hi, i have a radio button. On clicking the radio button i have to clear the already existing tablestyle of my datagrid and bind a new table to the grid with a new tablestyle. i used, ...
7
by: Andrus | last post by:
var db = new MyDb(connString); causes creation of all objects corresponding to all tables in database. Database contains 500 tables. Application accesses only few tables at a time. Creating...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.