473,626 Members | 3,325 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 1411
NeoPa
32,567 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
35669
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 fields. Can this be done in an Access db? I am trying to learn how to do these things in Access vs Visual Dim strIIF As String Dim sstrIIF As String Dim strNewDate As Date
2
9265
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 got created. But While calling the procedure using the statement
0
1426
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 am passing the SQL Statement as a string into a datasource property of a recordset. Can you please give me a source code on how to do it. What datatype should i used for the image file?
0
1713
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 can i print on VDU without using printf statement.
5
4371
by: konaravikumar | last post by:
writing a query to get the second highest value in atable by using select statement
1
1792
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
5488
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, _ , _ " = " & Something
1
2565
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) && tarikhRo.Equals(sdr)) {
2
1524
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 , txtXMLName.Text , lblCustID.Text is BLANK, It should not activate FCreateXMLFile() Function. I am using IF Statement to validate data and it generate this error message to my surprise. Error 2 Operator '||' cannot be applied to operands of type 'bool'...
0
8199
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8638
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8365
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4092
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2626
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.