473,671 Members | 2,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to hide a table that is made with SQL "CREATE TABLE"?

jbt007
40 New Member
All,

Access 2003 - WinXP

I thought this would be a no brainer, but it seems to be a perplexing problem. I have a simple table I use for importing several text reports, use VBA to run through the report to move data into tables. The temp table stays in access (tblTxtRpt), until the next report is imported, I then use SQL to DROP TABLE and CREATE TABLE to recreate it. This is because the table has an autonumber field that numbers the text report lines when it's imported. It is very important the records stay in the exact order of the report because data records on the report are on several lines.

What I want to do is hide this table so it doesn't show. Here are the things I have tried:

1. Naming the table MsysTxtRpt - Thinking that Access would consider this a system table and keep it hidden. This didn't work.

2. After creating the table I added code:
Expand|Select|Wrap|Line Numbers
  1. Application.SetHiddenAttribute acTable,"tblTxtRpt", True
This too did not work.

3. After creating the table I also tried;
Expand|Select|Wrap|Line Numbers
  1. Access.CurrentDb.TableDefs("tblTxtRpt").Attributes = dbHiddenObject
which also failed.

The reason I use DROP TABLE and CREATE TABLE is that access will not let you start an AutoNumber field over at "1" after you "DELETE tblTxtRpt.* FROM tblTxtRpt" It picks up where the last record ended. Due to the number of records (10,000+) in the txt report and the number of reports being imported, the AutoNumber field would quickly get very large and out of control. Dropping the table and adding it again solved this issue.

Here's my code for the process:

Expand|Select|Wrap|Line Numbers
  1.     'Import the text report into the temp table.
  2.     'Initialize variables
  3.     Set db = Access.CurrentDb
  4.     strSQL = "DROP TABLE tblTxtRpt;"
  5.  
  6.     'Delete the tblTxtRpt table if it is still in the db
  7.     For Each tbl In db.TableDefs
  8.         If tbl.name = "tblTxtRpt" Then
  9.             db.Execute strSQL, dbFailOnError
  10.             Exit For
  11.         End If
  12.     Next
  13.  
  14.     'Create a new tblTxtRpt to import the text report (Projection, Weekly, Monthly, etc. all use same table...
  15.     strSQL = "CREATE TABLE tblTxtRpt ([RawRec] Text(200), [RecID] AutoIncrement);"
  16.     db.Execute strSQL, dbFailOnError
  17.  
  18.     'Hide the temporary table (tblTxtRpt)...
  19.     Access.CurrentDb.TableDefs("tblTxtRpt").Attributes = dbHiddenObject
  20.     'To unhide, unremark the below line and remark out the line above...
  21.     'Access.CurrentDb.TableDefs("tblTxtRpt").Attributes = 0
Any thoughts or suggestions from the experts out there would put you on my Christmas, Hanukkah, etc. list!

Thanks,
Dec 17 '10 #1
2 3388
gershwyn
122 New Member
I'm not sure how to programmaticall y hide a table, but one thing you might try is instead of dropping the entire table, just drop the autonumber field.

Expand|Select|Wrap|Line Numbers
  1. ALTER TABLE tblTextRpt DROP RecID
  2. ALTER TABLE tblTextRpt ADD RecID Counter
If you use that to reset the autonumber field of an already hidden table, it will stay hidden.
Dec 17 '10 #2
jbt007
40 New Member
gershwyn - Thanks for the suggestion, however in testing I find that dropping just the field and adding again does not reset the AutoNumber back to 1. I have no idea how access trcks this number, but it doesn't seem to be reset when the field is deleted / re-added.
Dec 21 '10 #3

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

Similar topics

2
8682
by: Robin Tucker | last post by:
I have some code that dynamically creates a database (name is @FullName) and then creates a table within that database. Is it possible to wrap these things into a transaction such that if any one of the following fails, the database "creation" is rolledback. Otherwise, I would try deleting on error detection, but it could get messy. IF @Error = 0 BEGIN SET @ExecString = 'CREATE DATABASE ' + @FullName EXEC sp_executesql @ExecString
8
3557
by: cainlevy | last post by:
I'm wondering if there's any way to speed up create table queries? Besides upgrading hardware, that is. The very simplest table creation query, "create table table1 ( field1 INT(10))" is taking about .03 seconds, which compared to other queries (large inserts at .01 seconds) and previous experience appears inordinately long. Further, it appears that most of that .03 seconds is some kind of overhead, since the complexity of the create table...
2
7053
by: Alanoly J. Andrews | last post by:
Hi, I have two tables (that I know of) in a database that seem to be corrupted. All SQL statements on the tables hang, "select * from..", "select count (*) from", "delete from..". I can't even drop the tables as the "drop table..." statement, too, hangs. But the tables do exist as they show up in "describe table <tabname> ". A "create table" statement fails saying that the table already exists.
1
7247
by: DB_2 | last post by:
Greetings, I was searching Google for ways to turn off transaction logging for some queries. I came across this old post from Feb 2003: > From: fareeda (fareeda@pspl.co.in) > Subject: Re: Question related to "CREATE TABLE AS SELECT" in DB2 > Newsgroups: comp.databases.ibm-db2 > Date: 2003-02-27 21:11:59 PST >
7
5887
by: alessandro menchini | last post by:
Hello, First of all: i apologize for my english...i'm still learning... If i create a view it seems that DB2 manage this view like an updateable view. But I need to create a view "read only", so DB2 never enables lock on any record... How can i do that?
1
2357
by: pat | last post by:
I know this is a long shot, but is there any way of dumping a bunch of SQL "create table" statements from an existing Access 2003 database, to say for example, convert the database to MySQL/Oracle. -pat.
1
12761
by: dave.j.thornton | last post by:
I'm attempting to create a new table, and populate it using the fields from two existing tables. The code is printed below. I get the error: "Run-time error '-2147217900 (80040e14)': Syntax error in CREATE TABLE statement." For what it's worth, when tested independently, the "SELECT " part of my CREATE TABLE statement works properly. Sub test() Dim cmd As ADODB.Command Set cmd = New ADODB.Command
1
6432
by: msg2ajay | last post by:
hi, i am working on <div> i have to hide some part of the table. I am not able to hide that table part can anybady tell me where is the error. <html> <head> <script type="text/javascript"> function callme(){ document.getElementById("hid").style.visibility="visible"; }
5
2718
by: GHUM | last post by:
hello, in my application I am using hSem = win32event.CreateSemaphore (None, 1, 1,"stringincludinginterfaceandport") rt=win32event.WaitForSingleObject (hSem, 0) if rt != win32event.WAIT_TIMEOUT: really_do_start_my_app() else:
0
8397
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8919
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8821
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8599
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4409
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2813
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.