473,670 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TableDefs not recognized (I think?)

21 New Member
I am writing some code to seen if an import error table has been created.

When using the VBA editor in Access and I type in lowerrcase the following two statements
dim db as DAO.database
dim td as DAO.tabledef

it corrects it to
Dim db As DAO.Database
Dim td As DAO.TableDef
recognising the reserved words each time. However typing
Dim mydefs As DAO.TableDefs
is reverting to lowercase 'tabledefs' AND no subsequent code referring to 'mydefs' or any code with 'TableDefs' appears to be recognized or actioned.
This is happening regardless of whether I use 'DAO' or not.
Am I missing something or using the wrong syntax for tabledefs? Anybody else had the same problem?

Any help thankfully received.
Sep 1 '10 #1
6 4248
gershwyn
122 New Member
The TableDefs collection is a member of the Database object. I get an error when I refer to tabledefs or dao.tabledefs, but the following works fine:

Expand|Select|Wrap|Line Numbers
  1. msgbox CurrentDb.TableDefs.Count
Sep 1 '10 #2
missinglinq
3,532 Recognized Expert Specialist
It think it should be TableDef, as in the example that works, not TableDefs, which doesn't. Try dropping the s from the end.

Linq ;0)>
Sep 1 '10 #3
Deekay
21 New Member
Thank you Gershwyn and Missingling for your replies.
db.tabledefs.co unt appears to be working so that is recognized. Tabledefs is definately different to tabledef I believe where the first refers to the collection of tables and the second is used to refer to an individual table. But following on from my previous post...

str = mydefs.td.name (where str is a string variable)

is generating an error on compiling as not recognized.

Any further thoughts from anyone?
Sep 1 '10 #4
gershwyn
122 New Member
There is no member of the tabledefs collection called "td" so that will give an error. td is an object variable you've defined yourself.

The syntax to get the name of the first tableDef object in the collection would be this:
Expand|Select|Wrap|Line Numbers
  1. tblName = mydefs(0).Name
If you know the name, you can also refer to it this way:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print myDefs("TableName").RecordCount
Note: Str is the name of a built in function in Access, so I would avoid using it as a variable name.
Sep 1 '10 #5
Stewart Ross
2,545 Recognized Expert Moderator Specialist
As Linq and Gershwyn have indicated, you appear to be trying to access the tabledefs collection itself instead of the relevant tabledef contained within the collection. I'm not sure why you'd want to do so, as all the applications of the tabledefs collection I know of result from retrieving a given tabledef from the collection and working on that.

The Tabledefs() collection is not an object which you can declare in the way you have tried; it is a container for the objects within it. If you wanted to declare an object as a copy of your tabledefs collection as far as I can tell you'd have to declare it as a Collection object. I don't think this is at all necessary.

I have found that if you use the CurrentDB function to return the Tabledefs collection you can get problems with apparent lack of consistency of updates etc. In these circumstances it is best to declare a new database object, assign it the value of CurrentDB, then refer to the Tabledefs collection of that object for whatever you need to do, as shown in the example below:

Expand|Select|Wrap|Line Numbers
  1. Dim MyDb as Database
  2. Dim MyTableDef as DAO.Tabledef
  3. Set MyDb = CurrentDB
  4. Set MyTableDef = MyDb.Tabledefs("sometablename")
  5. ...
-Stewart
Sep 1 '10 #6
Deekay
21 New Member
Thanks for the various contributions - have solved it now!
(Still strange that in declaring tabledefs it reverts to lowercase whereas other declarations using reserved words capitalise in some way - as has happened using a code based on Stewart's suggestion (and which works) - somthing I'm still not understanding.)
Sep 2 '10 #7

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

Similar topics

2
2410
by: Shane Suebsahakarn | last post by:
Hi all, Does anyone have any idea why creating a table link across a network should be so slow? My front end app follows these steps when opening: * Retrieve all linked tables in the current database as a recordset from the MSysObjects table. * For each record: Check the existance of the mdb file that the table resides in. If the mdb file exists, check the table exists by opening the target
2
2378
by: BUX | last post by:
I have to look in Index property of myTable, but Set myTableDef = myDB.TableDefs(myTable) is so slow .... Do you now any other fast way? thank you
2
10582
by: Dave | last post by:
Help! When I try to run tblimp from the command line I get the following error: tblimp is not recognized as an internal or external command. tblimp.exe is not on my harddrive at all. What do I do?
1
1855
by: melanieab | last post by:
Hi again, With much help, I've finally gotten the Tab key to be recognized when a textbox is in focus, but now I'm having trouble with the up/down keys when they're focused on a custom button (on KeyDown, when I ask to show keyCode, nothing happens (except for Enter) so the focus goes to some textboxes that should never receive focus). I can think of 3 options, but don't know how to do any of them: 1) Say that these textboxes should...
2
2020
by: dee | last post by:
Hi, ASP.NET is not recognized by my system (throws a fit at the site of a .aspx) I have the following setup: - Uninstalled and reinstalled Visual Studio Enterprise Edition.NET - IIS 5 is running fine - Windows 2000 Pro sp.2 - ASP apps run successfully
3
2104
by: KRC | last post by:
I am using an external object called WebZinc to help parse web pages in VB.net. I am trying to use a particular method following the example in the help reference but am unable to get VB.net to recognize it. The code example is: Dim containsWordA As Boolean = New TextProcessor("my string containing words").ContainsWord("containing") where TextProcessor is the object and ContainsWord is the method. VB.net underlines the TextProcessor...
10
16406
by: dba123 | last post by:
Why am I getting this error for Budget? Error: An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: String was not recognized as a valid Boolean. Public Sub UpdateCustomer_DashboardGraphs(ByVal sender As Object, ByVal e As System.EventArgs)
0
1407
by: srabani | last post by:
Hi Everybody, I am srabani I am new to this site. I am working on VBA DAO and come accross with a code For Each tbl In CurrentDb.TableDefs If InStr(1, tbl.Connect, "DSN=Speakers_Bureau;") > 0 Then q1 = tbl.name
5
8632
by: Kevin Burton | last post by:
I am trying an XSLT transformation using the XslCompiledTransform class. I get an exception when I call the Transform method. It seems to point to these two lines: <xsl:namespace name="{$schemaPrefix}" select="$schemaNamespace"/> <xsl:namespace name="{$prefix}" select="$targetNamespace"/> The exception looks like: System.Xml.Xsl.XslTransformException: 'select' is not a recognized extension
2
2203
by: timmg | last post by:
The following code works well except I can't think of an elegant way of checking for the existance of the named field prior to creating it. Suggestions? Public Sub pNewField() 'Add a new field to every table in the collection Dim strSQL As String Dim db As Database, tdf As TableDef, intI As Integer Set db = CurrentDb
0
8468
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8386
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
8814
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
8591
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
8660
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...
1
6213
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4209
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1792
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.