Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Opening a recordset from the current db

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don W - 04 Nov 2006 02:11 GMT
I get an invalid argument error when I try to open a recordset from the
current database table named dbo_CardHolder using this code:

   Dim rs As Recordset
   Set rs = CurrentDb.OpenRecordset("dbo_CardHolder", dbOpenTable)

Any ideas why this is invalid?
Rick Brandt - 04 Nov 2006 02:31 GMT
>I get an invalid argument error when I try to open a recordset from the
> current database table named dbo_CardHolder using this code:
[quoted text clipped - 3 lines]
>
> Any ideas why this is invalid?

Tables named dbo_something are usually links to SQL Server tables and I'm pretty
sure you cannot open a Recordset on a link of type dbOpenTable.  Try
dbOpenDynaset instead.

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

Don W - 04 Nov 2006 02:41 GMT
Yes, I did try opening the recordset using dbOpenDynaset with the same result
(invalid argument).
Rick Brandt - 04 Nov 2006 02:53 GMT
> Yes, I did try opening the recordset using dbOpenDynaset with the same result
> (invalid argument).

If you have references to both ADO and DAO you might need...

Dim rs As DAO.Recordset

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

Don W - 05 Nov 2006 01:59 GMT
Rick, thank you for your response!

I still don't know what was happening.  Tried the module on my home PC and
it worked.  I'm in the office now, and this is the line I used to get this
thing working at the office:
   Set rs = CurrentDb.OpenRecordset("SELECT * FROM CardHolder")
(note that the table name was changed from dbo_CardHolder to just
CardHolder, but the table name change had no effect on the issue.)

Here at the office I never could open the recordset using the table name.  
Oh well... it works using SQL.
jmorriz - 05 Nov 2006 17:41 GMT
You may try

Dim ds as dao.database
dim rs as dao.recordset

set ds = currentdb
set rs = ds.openrecordset("tablename", dbopendynaset)

Jim
>Rick, thank you for your response!
>
[quoted text clipped - 7 lines]
>Here at the office I never could open the recordset using the table name.  
>Oh well... it works using SQL.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.