Solved

Correct VBA / SQL statement please

Posted on 2012-04-04
2
222 Views
Last Modified: 2012-04-04
super quick one. I don't know how to use the update statement in sql

This is the essence of what I want:


strSql = "UPDATE " & SettingsTable & "SET [LastOOSLAImportDate] = (#" & Format(Date, "yyyy-mm-dd") & "#)"

SettingsTable is a variable I've defined. LastOOSLAImportDate is a field in the SettingsTable. The table doesn't have a bunch or rows, it's a simple non-indexed table with a few settings on it I use to retrieve settings from.

I want to update the one row thats in there to set LastOOSLAImportDate to today.

Cheers
0
Comment
Question by:RossDagley1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 500 total points
ID: 37805357
Is SettingsTable the name of the table or the name of a variable with the table name?

If it's the table name:
strSql = "UPDATE SettingsTable SET [LastOOSLAImportDate] = (#" & Format(Date, "yyyy-mm-dd") & "#)"

Open in new window

If it's a variable with the table name:
strSql = "UPDATE [" & SettingsTable & "] SET [LastOOSLAImportDate] = (#" & Format(Date, "yyyy-mm-dd") & "#)"

Open in new window

Which is basically the same as your code, but wiht [] added in case the table name has spaces.
0
 
LVL 2

Author Comment

by:RossDagley1
ID: 37805363
strSql = "UPDATE [" & SettingsTable & "] SET [LastOOSLAImportDate] = (#" & Format(Date, "yyyy-mm-dd") & "#)"
                                            

Open in new window


That's the ticket - thanks very much. I just couldn't get the formatting right!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

623 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