473,624 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Counting Columns in a table using code

As any good code pirate would, I have duly copied the code suggested in
this forum from 1998(VBA method to determine number of columns in a
table??) but I keep getting an error "Object Required"...

ColumnNum = db.TableDefs(QT able1).Fields.C ount

http://groups.google.ca/group/comp.d...1aa8a5d4841b0).

While I am very happy to change with the times, I would like it if I
could get the rather simple code to work... I have a feeling the answer
is going to be rather simple.

Cheers

Reg

Nov 13 '05 #1
4 6759
Br
Regnab <p.*******@gmai l.com> wrote:
As any good code pirate would, I have duly copied the code suggested
in this forum from 1998(VBA method to determine number of columns in a
table??) but I keep getting an error "Object Required"...

ColumnNum = db.TableDefs(QT able1).Fields.C ount

http://groups.google.ca/group/comp.d...1aa8a5d4841b0).

While I am very happy to change with the times, I would like it if I
could get the rather simple code to work... I have a feeling the
answer is going to be rather simple.

Cheers

Reg


Umm, did you set the value of db??

eg.
Dim db as Database
Set db = CurrentDB()

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #2
Yep - that'd be the problem. Like I said - a bit of a beginner. Cheers
Brad. Problem now is I'm getting a "User-defined type not defined"
error on the 'Dim db as Database' which I think is related to my
references, but not sure. Another basic solution I'm guessing... ideas?

Nov 13 '05 #3
you need to register the DAO library. ADO is the default for all
versions after 97.

Open a code window, Tools, References, and then click the DAO 3.x
reference.

Nov 13 '05 #4
Br
pi********@hotm ail.com wrote:
you need to register the DAO library. ADO is the default for all
versions after 97.

Open a code window, Tools, References, and then click the DAO 3.x
reference.


And if you have ADO and DAO registered you need to prefix which in your
declaration... good practice to do it at all times I reckon.

eg.

DIM myDB as DAO.Database

or

DIM myDB as ADODB.Database
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1875
by: adam | last post by:
Hello, I have a MySQL table that has (among other fields) an affiliate_id, affiliate_sub_id, and a response_code field. - affiliate_id stores the unique number of each of my affiliates. - affiliate_sub_id stores the affiliate ID of their affiliates. - response_code holds a number between 1 - 6.
3
3039
by: Viswanatha Thalakola | last post by:
Hello, Can someone point me to getting the total number of inserts and updates on a table over a period of time? I just want to measure the insert and update activity on the tables. Thanks. - Vish
1
2449
by: Brian Anderson | last post by:
Hello, I am creating a windows application with a data grid contained on it. I want to find out the number of columns contained in the data grid at runtime, but I am not sure how to do this. I know that when using ASP.NET the data grid control has a class called datagrid.columns.count that does this, however the windows data grid control does not have this class. Could anyone help with this?
8
1735
by: Brenda J. | last post by:
Hello all I'm sure this is a relatively simple query to create, but I can't seem to get my head around it. Here is an example of the two tables I am using: tblAccountTypes AccountTypeID AccountType AccountNumberRange
3
1956
by: Megan | last post by:
hi everybody- i'm having a counting problem i hope you guys and gals could give me some help with. i have a query that retrieves a bevy of information from several different tables. first let me give you a little background. this database is kind of like a human resources database. it collects info about people, where they work, and if they have any work-related issues where they work.
18
2931
by: ChadDiesel | last post by:
I appreciate the help on this group. I know I've posted a lot here the last couple of weeks, but I was thrown into a database project at my work with very little Access experience. No other employee knows anything about Access. I've searched Google Groups, and that has been a lot of help, but there are some questions that I just can't find the answer to. I'll try to take it easy on the group after this question. I have one more...
7
4800
by: sathyashrayan | last post by:
Group, Following function will check weather a bit is set in the given variouble x. int bit_count(long x) { int n = 0; /* ** The loop will execute once for each bit of x set,
2
2058
by: Wing | last post by:
Hi all, I am using Microsoft Visual Studio .NET 2003 to program my code. I have following question. I am trying to adding a few bound columns which from a dataset that containing 2 tables to a datagrid, and display to the user. once I run it, I have error msg: "A field or property with the name 'PhotoName' was not found on the
13
2481
by: scorpion53061 | last post by:
Very urgent and I am very close but need a little help to get me over the edge........ I need to write these columns to a html file with each row containing these columns (seperated by breaks). Currently this code write all columns to a single row which works but is not what the boss wants. If anyone has suggestions how you would do a report like this I very much would like to hear them as well. vb.net windows app. ...
0
8236
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
8173
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
8679
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...
1
8335
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
8475
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
7159
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6110
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
4079
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...
1
2606
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

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.