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 / Multiuser / Networking / July 2005

Tip: Looking for answers? Try searching our database.

Open a SQL Server linked table with Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cjdphlx - 19 Jul 2005 14:42 GMT
I have a linked SQL Server table in my database.  I can edit and add
records to this table using bound forms.  However, in my database I
have unbound forms, which add new records.  My problem is I've been
unable to open the table with code.

My previous code was the basic:

    Set mydb = CurrentDb
    Set myTable = mydb.OpenRecordset("tblReportData", dbOpenTable)

    With myTable
         .AddNew
          ![Review Date] = txtReviewDate
          ![Analyst] = cboAnalyst
          ![Report Name] = cboReportName
          ![Report Date] = txtReportDate
          ![Review Time] = txtReviewTime
          ![Comments] = txtComments
          .Update
          .Close
      End With

This code no longer works.  I made sure the table name was the same as
the linked table but it still does not work.  I have no idea why this
is not working.  I believe I need to set up some kind of connection to
the SQL Server Database but I really have no idea what I'm doing
here.

Does anyone know how to open a SQL Server linked table for additions
with VBA code?
Brendan Reynolds - 20 Jul 2005 11:34 GMT
You can't use dbOpenTable with linked tables. Try changing it to
dbOpenDynaset, or just leave it out, as dbOpenDynaset is the default for
linked tables.

Signature

Brendan Reynolds (MVP)

>I have a linked SQL Server table in my database.  I can edit and add
> records to this table using bound forms.  However, in my database I
[quoted text clipped - 26 lines]
> Does anyone know how to open a SQL Server linked table for additions
> with VBA code?
Gary Walter - 20 Jul 2005 13:51 GMT
PMFBI

I wondered also if wouldn't need "dbSeeChanges" probably:

Set myTable = mydb.OpenRecordset("tblReportData", dbOpenDynaset,
dbSeeChanges)

apologies again,

gary
Brendan Reynolds - 20 Jul 2005 16:04 GMT
No apology necessary, Gary, I'm glad you thought of that, as I had forgotten
about it.

Signature

Brendan Reynolds (MVP)

> PMFBI
>
[quoted text clipped - 6 lines]
>
> gary
Tony Toews - 21 Jul 2005 00:51 GMT
>I wondered also if wouldn't need "dbSeeChanges" probably:
>
>Set myTable = mydb.OpenRecordset("tblReportData", dbOpenDynaset,
>dbSeeChanges)

Ayup.  I sure wish MS would just make this the default for SQL Server
linked tables and be done with it.

Tony
Signature

Tony Toews, Microsoft Access MVP
  Please respond only in the newsgroups so that others can
read the entire thread of messages.
  Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm

 
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.