We help IT Professionals succeed at work.
Get Started

Access VBA - updating query with relationships to tables linked via ODBC and SQL Server

Last Modified: 2016-02-11
Please note I have the following code:

It runs - doesn't cause an error but does not actually update the SQL Server tables.
The SQL Server tables are the ones not listed with the term TEMP in front.   The tables that have TEMP in front are local tables.   I checked in the TEMPSessionsEntry and the data is in there already updated.  It's just not updating LSSessions...

Any ideas on how I may make the update SQL work?

I have bound forms tied to the local TEMP tables.   At the beginning I load the TEMP tables with what's SQL Server - when they make an edit - I have this update query ran.

  sSQL = "UPDATE TEMPSessionsEntry INNER JOIN LSSessions ON TEMPSessionsEntry.LSID = LSSessions.LSID SET LSSessions.Title = [TEMPSessionsEntry].[Title], LSSessions.LSDescription = [TEMPSessionsEntry].[LSDescription], LSSessions.Presenter = [TEMPSessionsEntry].[Presenter], LSSessions.Keywords = [TEMPSessionsEntry].[Keywords], LSSessions.EventStartDate = [TEMPSessionsEntry].[EventStartDate], LSSessions.EventEndDate = [TEMPSessionsEntry].[EventEndDate],"
  sSQL = sSQL & " LSSessions.StartDate = [TEMPSessionsEntry].[StartDate], LSSessions.CompDate = [TEMPSessionsEntry].[CompDate], LSSessions.EventStartTime = [TEMPSessionsEntry].[EventStartTime], LSSessions.EventEndTime = [TEMPSessionsEntry].[EventEndTime], LSSessions.Type = [TEMPSessionsEntry].[Type], LSSessions.Hours = [TEMPSessionsEntry].[Hours], LSSessions.CreditValue = [TEMPSessionsEntry].[CreditValue],"
  sSQL = sSQL & " LSSessions.FirmWide = [TEMPSessionsEntry].[FirmWide], LSSessions.LocationID = [TEMPSessionsEntry].[LocationID],"
  sSQL = sSQL & " LSSessions.LocalTo = [TEMPSessionsEntry].[LocalTo], LSSessions.MinCapacity = [TEMPSessionsEntry].[MinCapacity], LSSessions.MaxCapacity = [TEMPSessionsEntry].[MaxCapacity], LSSessions.EnrollStartDate = [TEMPSessionsEntry].[EnrollStartDate], LSSessions.EnrollEndDate = [TEMPSessionsEntry].[EnrollEndDate], LSSessions.EnrollCancelDeadline = [TEMPSessionsEntry].[EnrollCancelDeadline], LSSessions.VendorID = [TEMPSessionsEntry].[VendorID], LSSessions.LunchNLearn = [TEMPSessionsEntry].[LunchNLearn],"
  sSQL = sSQL & " LSSessions.NotOkOthersEnroll = [TEMPSessionsEntry].[NotOkOthersEnroll],"
  sSQL = sSQL & " LSSessions.UserEntered = [TEMPSessionsEntry].[UserEntered]"
  lArea = 1
  CurrentDb.Execute sSQL, dbSeeChanges

Open in new window

Watch Question
Principal Analyst
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE