strange errors when using Access objects

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anybody please explain the following errors, both of which contravene
examples posted in this list and/or the Help for DAO ?

(1)
Dim db As DAO.Database
Set db = Application.CurrentData

--> Error 13: Type mismatch.

.... I can avoid this error by using "Dim db As Object" instead. Why?

(2)
Dim td As DAO.TableDef
Set td = Application.CurrentData.CreateTableDef("test")

--> Error 438: Object doesn't support this property or method.

.... I can't get past this; my project is halted. This example is not
different from that in the Help page on the CreateTableDef method, so what
could be wrong?

(-- increasingly frustrated and thinking about chucking Access in the bin
and doing everything in VB6 !)
 
Try:
Set db = CurrentDb()

Then:
Set td = db.CreateTableDef(...

If that still fails, choose References on the Tools menu (in the code
window), and check the box beside:
Microsoft DAO 3.6

BTW, it is faily unusual to be creating tables in code.
 
Thanks, Allen: that worked. However, I wish I could see some rhyme or reason
to the variations in acceptable syntax between one program context and
another.

I take your point about creating a table in code. But, this will be a lookup
table with 10,966 x 10,966 entries, and I didn't know how else to do it. (The
table only needs to be created once, and the interactive aspects of my
project will then query it.)
 
The reason why

Dim db As DAO.Database
Set db = Application.CurrentData

fails is that Application.CurrentData returns an ADO Connection object, and
you're trying to assign that to a DAO Database object. It's the same as
trying to assign a text string to a numeric field.

Not sure exactly what you mean by "a lookup table with 10,966 x 10,966
entries". To me, that implies you want a table with 10,966 rows and 10,966
columns. That ain't going to happen: Access has a 255 field limit on tables.
If this is a one-time use thing, can you perhaps just create an array in
memory (or are you using the table in a query)?
 
Thanks for the expanation, Doug.

I realised last night that a BFI approach wasn't going to fly. (An array of
10^8 elements? What was I thinking.) I'm now going to reduce the size of the
source table via a query that applies criteria I would have used at a later
stage of the analysis, anyway. If the resulting lookup table is still too
big, I will try writing it to a binary file in VB, and arrange for my
database to read this file when an essential query opens.
 
Doug,

Sorry to get off-topic, but your home page () has been
corrupted or hijacked by 'Error Safe'.

Regards,
Allen Nugent
(an engineer who used to live in Canada and brew beer)
 
Actually, the problem seems to be intermittent. It worked the last few
tries. Looks as though they're now insisting on including their advertising,
and at least one of the advertisers doesn't play well with my home page.
 
Back
Top