473,498 Members | 1,907 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(QTable1).Fields.Count

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 6745
Br
Regnab <p.*******@gmail.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(QTable1).Fields.Count

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********@hotmail.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
1866
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. -...
3
3028
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....
1
2436
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...
8
1721
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 ...
3
1951
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...
18
2915
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...
7
4782
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
2050
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...
13
2463
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)....
0
7004
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...
1
6890
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...
0
7379
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...
0
5464
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,...
1
4915
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...
0
4593
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...
0
1423
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 ...
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
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...

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.