By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

No Answer Yet.....

P: n/a
I can post the code, but let me clarify my previous attempts. I should
mention I've had no trouble with VBA programs in the past, with or w/o OBDC.
After several frustrating attempts, quite a bit of research, etc. I tried
pasting in routines from the VB Help file and from Microsoft's MSDN site.
They give the same "User-defined type not defined" error, in the same place
in the code (the very beginning), that I recceived with my code.

The first few lines of the code (this from MS):

Dim wrkODBC As Workspace
Set wrkODBC = CreateWorkspace("ODBCWorkspace", "", "", dbUseODBC)
'tried with a UserID also
DefaultType = dbUseJet 'tried with and w/o this statement
Set wrkJet = CreateWorkspace("", "", "")

The error I mentioned refers to the "Dim" statement as the source of the
error.

Thanks for the reply -- Whatever I'm doing wrong, or not doing, is probably
something simple, but I can't put my finger on it.....

Mike Reed

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:9c********************@rogers.com...
We'll need to see your code.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"mr_wizard" <mr****@cablespeed.com> wrote in message
news:vc********************@cablespeedmi.com...
Before I retired, I was a systems analyst with the State of MI. We used
Access as several of our databases.

I want to use VB5 to write programs that will access my Access databases

via
ODBC. Every attempt fails at the beginning, where the connection info is
Dim'ed, with the error "User-defined type not defined". What am doing

wrong?

Thanks, Mike Reed



Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Have you made sure that you have DAO selected in the references?
Alex

"mr_wizard" <mr****@cablespeed.com> wrote in message
news:Yp********************@cablespeedmi.com...
I can post the code, but let me clarify my previous attempts. I should
mention I've had no trouble with VBA programs in the past, with or w/o OBDC. After several frustrating attempts, quite a bit of research, etc. I tried
pasting in routines from the VB Help file and from Microsoft's MSDN site.
They give the same "User-defined type not defined" error, in the same place in the code (the very beginning), that I recceived with my code.

The first few lines of the code (this from MS):

Dim wrkODBC As Workspace
Set wrkODBC = CreateWorkspace("ODBCWorkspace", "", "", dbUseODBC)
'tried with a UserID also
DefaultType = dbUseJet 'tried with and w/o this statement
Set wrkJet = CreateWorkspace("", "", "")

The error I mentioned refers to the "Dim" statement as the source of the
error.

Thanks for the reply -- Whatever I'm doing wrong, or not doing, is probably something simple, but I can't put my finger on it.....

Mike Reed

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:9c********************@rogers.com...
We'll need to see your code.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"mr_wizard" <mr****@cablespeed.com> wrote in message
news:vc********************@cablespeedmi.com...
Before I retired, I was a systems analyst with the State of MI. We used
Access as several of our databases.

I want to use VB5 to write programs that will access my Access databases
via
ODBC. Every attempt fails at the beginning, where the connection info

is Dim'ed, with the error "User-defined type not defined". What am doing

wrong?

Thanks, Mike Reed



Nov 13 '05 #2

P: n/a
I'm not quite sure what you mean when you ask "Do I have DAO selected in
the references." As I mentioned, every routine I've pasted in (out of
frustration) from the VB Help File and MSDN errors on the very first
line of the program. I various DIM statements at the beginning (from the
pasted-in code). It errors on the first Dim statement. If I remove it,
it errors on the now-new first line, etc., etc.

I posted the first few lines in my earlier post. Very frustrating....!

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

P: n/a
On 6 Jan 2005 16:30:28 -0600, Mike Reed <mr****@cablespeed.com> wrote:
I'm not quite sure what you mean when you ask "Do I have DAO selected in
the references." As I mentioned, every routine I've pasted in (out of
frustration) from the VB Help File and MSDN errors on the very first
line of the program. I various DIM statements at the beginning (from the
pasted-in code). It errors on the first Dim statement. If I remove it,
it errors on the now-new first line, etc., etc.

I posted the first few lines in my earlier post. Very frustrating....!

Mike


Mike, search Google on "References" and "DAO". What you want to do is
when the thing stops dead in its tracks, click on "TOOLS"|"REFERENCES"
and then make sure that "Data Access Objects (x.xx)" is selected. You
might need to actually move it up in the list, too, to make sure it is
the first thing that Access makes use of (beyond the top 2 or three
which can't be relegated to anything lower than what they already
are).

Once you have made sure that the DAO reference is "active", you should
no longer get an error on the first DIM statement you run into.

Good luck.

mike
Nov 13 '05 #4

P: n/a
The way most of the Microsoft world works, functionality comes from various
components. Rather than building data access functionality into VB and VC++
and VBA and..., all of them get the necessary functionality from the same
COM object.

Your sample code is trying to use DAO to communicate with the Jet database.
That means you have to tell VB where to get the DAO components. You do that
by select Project | References on the menu bar, scrolling through the list
of available references until you find the Microsoft DAO 3.x Object Library
listing, select it then close the dialog. If you're going against Access 95
databases, you select DAO 3.0. If you're going against Access 97 databases,
select DAO 3.5x, or DAO 3.6 for Access 2000 and newer.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Mike Reed" <mr****@cablespeed.com> wrote in message
news:41**********@127.0.0.1...
I'm not quite sure what you mean when you ask "Do I have DAO selected in
the references." As I mentioned, every routine I've pasted in (out of
frustration) from the VB Help File and MSDN errors on the very first
line of the program. I various DIM statements at the beginning (from the
pasted-in code). It errors on the first Dim statement. If I remove it,
it errors on the now-new first line, etc., etc.

I posted the first few lines in my earlier post. Very frustrating....!

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #5

P: n/a
Thanks, Mike. I now "have it." Your tips did the trick. Got direct and
ODBC working. Thanks a million.

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #6

P: n/a
Thanks, DOug. Your tip did the trick, but I *really* appreciate your
explanation of how DAO interfaces with VB. It does not serve me to only
get it working, I want to know the how, why, etc. You explained it very
well. Thanks a million.

"You're a lifesaver, Mr. Obvious...."

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.