Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 11th, 2003, 06:48 PM
easy easy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 16 easy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 15 sec
Reputation Power: 0
var as Database won't work in Access 2K- help

my objective is simply to see if a table has any records in it. In access 97, here is the code I use, and it does the job:

(I know this is VBA, but I thought using the php tag would make it easier to read)

PHP Code:
 Dim dbs As Database
Dim rst 
As Recordset

Set dbs 
CurrentDb

Set rst 
dbs.OpenRecordset("tblSomeTable"dbOpenDynaset)

If 
rst.RecordCount <> 0 Then

//I put more code here, but that's not part of the problem

end if 


the error message is: "Compile error: User-defined type not defined"

and it's referring to the "As Database" bit. Apparently "Database" is not a valid object or class (or whatever) in Access 2000, though it was in '97.

So, any thoughts on what I can do? All I really need is for it to look in my table and tell me if it has any records. There must be an easy way to do that

Reply With Quote
  #2  
Old November 11th, 2003, 07:03 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
U can try to install MDAC2.8 http://msdn.microsoft.com/isapi/gom...&DisplayLang=en ..And Retry to recpomlie the project..

Reply With Quote
  #3  
Old November 11th, 2003, 07:19 PM
easy easy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 16 easy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 15 sec
Reputation Power: 0
I'm a bit of a beginner.. I have Access 97 and 2000 both installed on my PC- if it works on 97, would installing that MDAC2 still help? thanks for your reply, though. I'll probably try it later tonight, just to see

Reply With Quote
  #4  
Old November 11th, 2003, 09:42 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,717 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 40 m 34 sec
Reputation Power: 688
Try adding a reference to DAO in your Access 2000 project. In the VBA editor choose Tools - References

Reply With Quote
  #5  
Old November 12th, 2003, 11:28 AM
easy easy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 16 easy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 15 sec
Reputation Power: 0
Quote:
Originally posted by Doug G
Try adding a reference to DAO in your Access 2000 project. In the VBA editor choose Tools - References


wow, I can't beleive it was that simple. Thanks for the help, guys.

Could you take a look at the code, though? I'm thinking there must be an easier way to check a table to see if there's anything in it. Any ideas for that?

Reply With Quote
  #6  
Old November 12th, 2003, 11:49 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Would u check the table exists or inexists??
This code u can try:
dim db as database, td as tabledef
set db = currentdb()
on error resume next
set td = db.tabledefs("MyTable")
if err.number <> 0 then set td = nothing
on error goto 0

if td is nothing then
' table did not exist.
else
' table exists, and its properties are in td.
...
set td = nothing
endif
set db = nothing

To check in some other database, use:
set db = dbengine.opendatabase ("path to other database")

and add as the second-last line:
db.close

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > var as Database won't work in Access 2K- help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway