473,499 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using FileDateName in SET statement

4 New Member
I have a scenario where I receive an Excel spreadsheet that cross-references some date I have stored in a table. I need to update the table data using the common element and insert the Time/Date stamp from the Excel files into a field in the table. I have no issues getting the Time/Date stamp:

Expand|Select|Wrap|Line Numbers
  1. Dim filedate As Date
  2. Dim sSQL As String
  3.  
  4. If sXlx <> "" Then
  5.  
  6.         ' Load Inbond SS >>>
  7.         If DCount("[Name]", "MSysObjects", "[Name] = 'xls_Inbond_staging'") = 1 Then
  8.             DoCmd.DeleteObject acTable, "xls_Inbond_staging"
  9.         End If
  10.  
  11.         DoCmd.SetWarnings False
  12.         DoCmd.TransferSpreadsheet acLink, 8, "xls_Inbond_staging", my_path & sXlx, False
  13.         DoCmd.SetWarnings True
  14.  
  15.         filedate = filedatetime(sXlx)
  16.  
  17.         sSQL = ""
  18.         sSQL = sSQL & "INSERT INTO tbl_Inbond_staging        (MBOL) " ' 1
  19.         sSQL = sSQL & "SELECT F30 " ' MBOL
  20.         sSQL = sSQL & "FROM xls_Inbond_staging "
  21.         sSQL = sSQL & "WHERE F30<>'MasterBillNumber' "
  22.         sSQL = sSQL & "AND nz(F30,'')<>'';"
  23.         Call CurrentDb.Execute(sSQL)
  24.  
  25.         sSQL = ""
  26.         sSQL = sSQL & "UPDATE tbl_Inbond_staging "
  27.         sSQL = sSQL & "SET tbl_Inbond_staging.FileDT = FileDateTime(sXlx);"
  28.         Call CurrentDb.Execute(sSQL)
  29.  
Embedding FileDateTime in the SET statement gives an error. I've tried several iterations of using filedate in the SET statement, but none of them will give me the value in filename. Appealing to the group for help - thank you!
Nov 27 '19 #1
1 1396
NeoPa
32,557 Recognized Expert Moderator MVP
KerryOkie:
Embedding FileDateTime in the SET statement gives an error.
No surprise there.

The Expression Service, that interprets and executes the SQL, has no point of reference for FileDateTime() which is available to your VBA only because you have a reference set to it (The full reference in VBA is VBA.FileSystem.FileDateTime()).

You will need to insert the literal value into your SQL string formatted in the correct way for SQL to recognise and process it correctly as a Date/Time :
Expand|Select|Wrap|Line Numbers
  1. sSQL = "UPDATE [tbl_Inbond_staging] " _
  2.      & "SET    [FileDT]=#%FD#;"
  3. sSQL = Replace(sSQL, "%FD", Format(FileDateTime(sXlx) _
  4.                                  , "yyyy\-m\-d HH:mm:ss")
Another point I'd warn you against is using the function CurrentDb() as if it were a variable. Though it returns similar objects each time it's run they're never actually the same one and this causes lots of people great confusion. Always do something as illustrated in :
Expand|Select|Wrap|Line Numbers
  1. Dim dbVar As DAO.Database
  2.  
  3. Set dbVar = CurrentDb()
  4. Call dbVar.Execute(...)
  5. ...
  6. Call dbVar.Execute(...)
  7. ...
  8. etc.
Nov 27 '19 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
35660
by: Bob | last post by:
Currently I am using this statement to translate 3 fields in my db thru Visual Basic. I import the data from one table to another then call the IFF statements and the NewDate to translate the...
2
9258
by: bashanitwonline | last post by:
Hi All, I have DB2 8.1 on my system. I have created a procedure as follows. CREATE PROCEDURE DB2ER000.XYZ() LANGUAGE SQL BEGIN INSERT INTO DB2ER000.A ( C,D,E) VALUES (10,20,30); END It...
0
1407
by: Lavs | last post by:
Hi Guys... Is there anyone who could help me on how to add an image file to a database using SQL Statement... I am using a database in MS ACCESS 2003, and my application was designed in VB 6.0. I...
0
1697
by: brainfulkale | last post by:
My question is that "How to print on VDU without using printf statement in unix" In DOS i use far pointer as cls { char far *s; s=0xB8000000; *s='A'; } But if i wanted to print in unix jow...
5
4353
by: konaravikumar | last post by:
writing a query to get the second highest value in atable by using select statement
1
1776
by: =?Utf-8?B?bGlhbnF0bGl0?= | last post by:
Is using a jump statement more faster than using if statement with a jump statement example for(int i=0; i < 10; i++) { if(a == null) {
8
5460
reginaldmerritt
by: reginaldmerritt | last post by:
Hi, I have two report layouts that are used to run 12 different reports using where statement. for example DoCmd.OpenReport "SomeReport", _ acViewPreview, _ ...
1
2556
by: sakura | last post by:
Hi. I'm using asp.net and c# language. How can i display a GridView using select statement of two column in one table? This is my coding: if (sdr.Read()) { if(namaPembekal.Equals(sdr)...
2
1512
by: lenniekuah | last post by:
Hullo Good Friends, I am back again seeking help. Please help me. I am using C#NET2008 Window Application, This is the situation. Should either one of this control, txtXMLFolder.Text ,...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4917
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.