Solved

Accessing a linked table

Posted on 1998-02-01
10
245 Views
Last Modified: 2010-08-05
I've linked a table in the external MS Access database using
File->Get External Data->Link Tables
I can browse this table and run queries on it, but I can't access it from VB code - it gives me "Member not found" error. The code runs fine on the imported table.
Do I have to do something special to treat a linked table in my code?
0
Comment
Question by:garik
  • 4
  • 4
  • 2
10 Comments
 

Expert Comment

by:DonHillsberry
Comment Utility
Please provide more information..
What version of Access and VB are you using?
What version of Access was used to create the database?
What type of database was used to create the table getting linked?

How are you accessing the database from VB?  Are you using a data control or DAO?

What exactly are you trying to do with the table?  Are you simply doing a select to retrieve records?
0
 
LVL 3

Author Comment

by:garik
Comment Utility
MS Access 97 is used for everything.
I might use a wrong term, but by VB I meant Visual Basic used to create procedures in the Access module.
I need to get a number of records in the linked table first and then go through each record and do some processing.
0
 

Expert Comment

by:DonHillsberry
Comment Utility
I have used linked tables from a VB program and never experienced a problem.  There are retrictions on modifying the table definition, but I haven't had any problems accessing data.

I have not tried accessing linked tables from VBA within Access, but I would be surprised if you have to do anything special within your code.

I don't think I'm going to be much help for you on this one.
0
 
LVL 12

Expert Comment

by:Trygve
Comment Utility
Could you provide the code, or parts of it, that gives you the problem. I have worked a lot on linked tables and could perhaps be of some assistants.
0
 
LVL 3

Author Comment

by:garik
Comment Utility
Function splitStyleOptions()
Dim db  As Database
Dim rsOptions As Recordset, rsFeatures As Recordset, rsIDs As Recordset, rsStyles As Recordset
Dim strBuf As String, tok As String
Dim i As Long, j As Long, m As Long, n As Long, cnt As Long

Set db = CurrentDb()
'
' Empty Styles-Features table
db.Execute ("delete from [Available IDs]")
'
Set rsIDs = db.OpenRecordset("Available IDs")
Set rsFeatures = db.OpenRecordset("Available Features", dbOpenTable)
Set rsOptions = db.OpenRecordset("select count(*) as RecNum from [Options]")
m = SysCmd(acSysCmdInitMeter, "Processing Available Features..", rsOptions.RecNum)
rsOptions.Close

...

Execution stops with a message: "Method or data member not found" and rsOptions.RecNum highlighted (in SysCmd statement). It always stops at the first call to a member of rsOptions.
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 12

Expert Comment

by:Trygve
Comment Utility
It seems to me like it is the RecNum that gives you the problem and not the linked table itself.

If you are trying to set the status bars maximum number you could try the following.

rsOptions.movelast ' Ensure correct record number
m = SysCmd(acSysCmdInitMeter, "Processing Available Features..", rsOptions.RecordCount) ' Set to the number of the last record.

rsOptions.movefirst ' Go to the top again.

...


Hope this helps !
Trygve
0
 
LVL 3

Author Comment

by:garik
Comment Utility
Nope. As I said in a previous comment, execution stops after the first call to a member of rsOptions - if it's not RecNum as in my sample code, then it's a first member accessed in a subsequent selects. Sorry.

0
 
LVL 12

Expert Comment

by:Trygve
Comment Utility
Sorry about. In my eager to answer the question I read your comment about getting the number of records and from there came my answer.

Remember when refering to fields in a table/recordset object you should use MyRecs!Field instead of MyRecs.Field   The "." is reserved for properties and events and the "!" is for field references.


What happens if you make a query with the same SQL statement "select count(*) as RecNum from [Options]" Does it return anything ?
0
 
LVL 3

Author Comment

by:garik
Comment Utility
You're right about "!" vs "." - it solved the problem.
Please pick up the points. Thanks!

0
 
LVL 12

Accepted Solution

by:
Trygve earned 100 total points
Comment Utility
Thanks a lot. OK here it is:

Remember when refering to fields in a table/recordset object you should use MyRecs!Field instead of MyRecs.Field The "." is reserved for properties and events and the "!" is for field references.

Have a nice day !
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now