Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 8th, 2008, 08:26 AM
kryles kryles is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 80 kryles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 6 m 45 sec
Reputation Power: 1
Create table (access 2000)

Hi, I am trying to create a table in VBA code. I checked msdn and googled a little bit and got some chunks I thought would work, but I get a data type conversion error. Any pointing in the right direction would be much appreciated.

Code:
Dim db As DAO.Database
Dim tblEmployees As DAO.TableDef
Dim fldEmployeeNumber As DAO.Field

' Specify the database to use
Set db = CurrentDb()

' Create a new TableDef object.
Set tblEmployees = db.CreateTableDef("Employees")

MsgBox ("here") 'gets here
Set fldEmployeeNumber = tblEmployees.CreateField("ID", "Text", 20)

MsgBox ("here1") 'never makes it here

tblEmployees.Fields.Append fldEmployeeNumber

' Add the new table to the database.
db.TableDefs.Append tblEmployees

Reply With Quote
  #2  
Old May 8th, 2008, 08:38 AM
kryles kryles is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 80 kryles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 6 m 45 sec
Reputation Power: 1
dbText instead of Text as type got me past that point. Heh

Reply With Quote
  #3  
Old May 8th, 2008, 01:50 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
You seem to have found the answer to your original question, but your question raises an issue to me: why would you want to create a new table (with just one field) in a VBA module? The reason I'm asking is that this is a huge red flag to an experienced developer. Modules are written to do repetitive operations, suggesting that maybe you're creating a new table frequently, which in turn suggests that you may be doing something quite unnecessary and even counterproductive. I'm going to guess that you're creating such tables to export for some other use, but that's rarely, if ever, needed. In any case, you could probably do that with a Make Table query. Possibly you have a valid reason that isn't apparent to me, but as I said, the fact that you're trying to do it at all raises a red flag to me.
Comments on this post
AOG123 agrees: @ kryles,.. Pay good attention to what Dons saying.. @Don. I could have done with you as my IT
teacher all those years ago,
__________________
Experience is the thing you have left when everything else is gone.

Reply With Quote
  #4  
Old May 8th, 2008, 02:00 PM
kryles kryles is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 80 kryles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 6 m 45 sec
Reputation Power: 1
Well it is a table used to hold data imported from a CSV. That info will be compared, updated and exported to a new csv daily. Then the table becomes unnecessary.

I figured I'd use a module because there is a lot existing code where this happens (we import 6 csv files daily, not to the same table).

What would you suggest is the better method normally?

Reply With Quote
  #5  
Old May 8th, 2008, 02:20 PM
rpeare rpeare is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 467 rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 4 Days 7 m 47 sec
Reputation Power: 117
So you import 6 CSV files daily, do some manipulation, then export them back to CSV files? Why?
__________________
----------------
If we've helped you and you have solved your problem please post that it's been resolved so we know! The suspense kills me!

Reply With Quote
  #6  
Old May 8th, 2008, 02:28 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
Quote:
Originally Posted by kryles
Well it is a table used to hold data imported from a CSV. That info will be compared, updated and exported to a new csv daily. Then the table becomes unnecessary.

I figured I'd use a module because there is a lot existing code where this happens (we import 6 csv files daily, not to the same table).

What would you suggest is the better method normally?

OK, then you're actually using Access as a data processing tool, not as a database. I've done that. As a database kinda guy, it pains me to do that, because it suggests that the entire operation ought to be a database application, but I admit that situations exist where there is no value at all in retaining the data, so I would not try to insist that it shouldn't be done.

So your solution may be quite reasonable. You might find it just as easy to use a Make Table query and just call it from your code, but there's nothing fundamentally wrong with doing it the way you are. I take it you solved your original problem?

@AOG123: You were probably too young, when I was teaching database classes!

Reply With Quote
  #7  
Old May 8th, 2008, 02:29 PM
kryles kryles is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 80 kryles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 6 m 45 sec
Reputation Power: 1
well we use Access, but our web hosting service wont allow for odbc (i think that's it, the thing that lets ACCESS and SQL talk).

So we need to export from web SQL, import to ACCESS, update shipping information on the supplied orders, export back to CSV and import back to web SQL.

That's the one I'm working on now. The others (done before I came on board) are supplied from us by call centers with no access to our internal database.

Before me the company never used VBA so we have a ton of queries that do one thing, so I'm trying to code and avoid clogging our already overly sized database (hindering at about 1.7Gigs all the time)

Reply With Quote
  #8  
Old May 8th, 2008, 03:26 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
Quote:
Originally Posted by kryles
well we use Access, but our web hosting service wont allow for odbc (i think that's it, the thing that lets ACCESS and SQL talk).

So we need to export from web SQL, import to ACCESS, update shipping information on the supplied orders, export back to CSV and import back to web SQL.

That's the one I'm working on now. The others (done before I came on board) are supplied from us by call centers with no access to our internal database.

Before me the company never used VBA so we have a ton of queries that do one thing, so I'm trying to code and avoid clogging our already overly sized database (hindering at about 1.7Gigs all the time)

OK. The Access Jet engine is perfectly happy with SQL (the language). ODBC is what allows Access to connect to non-Microsoft databases like Oracle, MySQL, etc. I'm not sure what "web SQL" implies, but I see your problem. There might be a general solution to such a problem, but it would be a bear to tackle. So your approach is probably a practical solution.

You are aware, I assume, of the 2 Gig limitation on an Access mdb. And do you regularly perform Compact/Repairs? That's the big problem with creating temp tables. Every time you create a new one, it requires more storage, even if you delete the old one! That's why temp tables are to be avoided like the plague, if you can possibly do so. If you can't, you have to perform frequent Compact/Repairs. That can be automated by doing it each time the mdb is opened (or closed, as I recall), although that can be annoying if you're trying to quickly open it to check something, and you have to wait for it to complete the C/R.

Anyway, you appear to have a valid purpose in creating these temp tables, in your operating circumstances. But more often than not, when I see someone creating such tables, it's because they're trying to do something the wrong way. That's why I pursued the point.

Reply With Quote
  #9  
Old May 8th, 2008, 03:56 PM
kryles kryles is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 80 kryles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 6 m 45 sec
Reputation Power: 1
Hrm, yah we even use a third party product to compact repair since we are normally going over the 2Gigs and performance is an ongoing issue. I've tried convincing to migrate to SQL back end and VB front end but suits always know better than us and they're happy with the constant battles

I wasn't aware that Temp tables made it more of a mess, since there is no auto-number maybe it makes more sense just to delete everything from a constant table at the end. Or does that make a mess too? Keep in mind we do use temp tables for all the CSV mentioned in above posts.

Reply With Quote
  #10  
Old May 8th, 2008, 07:12 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
Quote:
Originally Posted by kryles
Hrm, yah we even use a third party product to compact repair since we are normally going over the 2Gigs and performance is an ongoing issue. I've tried convincing to migrate to SQL back end and VB front end but suits always know better than us and they're happy with the constant battles

I wasn't aware that Temp tables made it more of a mess, since there is no auto-number maybe it makes more sense just to delete everything from a constant table at the end. Or does that make a mess too? Keep in mind we do use temp tables for all the CSV mentioned in above posts.

That won't help. Once an object has been allocated space, it is not overwritten (re-used) until you run Compact. Thus, record deletions are just like table deletions, and every time you modify and re-save a form or report or query, the mdb grows bigger. Before you do the next Compact, check the file size, then run your Compact utility and immediately check the file size again. You might consider migrating to MS SQL and just using Access as a front end, which usually works, often with some adjustments. But if your management just doesn't want to do it, I understand the problem.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Create table (access 2000)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway