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: -
Dim filedate As Date
-
Dim sSQL As String
-
-
If sXlx <> "" Then
-
-
' Load Inbond SS >>>
-
If DCount("[Name]", "MSysObjects", "[Name] = 'xls_Inbond_staging'") = 1 Then
-
DoCmd.DeleteObject acTable, "xls_Inbond_staging"
-
End If
-
-
DoCmd.SetWarnings False
-
DoCmd.TransferSpreadsheet acLink, 8, "xls_Inbond_staging", my_path & sXlx, False
-
DoCmd.SetWarnings True
-
-
filedate = filedatetime(sXlx)
-
-
sSQL = ""
-
sSQL = sSQL & "INSERT INTO tbl_Inbond_staging (MBOL) " ' 1
-
sSQL = sSQL & "SELECT F30 " ' MBOL
-
sSQL = sSQL & "FROM xls_Inbond_staging "
-
sSQL = sSQL & "WHERE F30<>'MasterBillNumber' "
-
sSQL = sSQL & "AND nz(F30,'')<>'';"
-
Call CurrentDb.Execute(sSQL)
-
-
sSQL = ""
-
sSQL = sSQL & "UPDATE tbl_Inbond_staging "
-
sSQL = sSQL & "SET tbl_Inbond_staging.FileDT = FileDateTime(sXlx);"
-
Call CurrentDb.Execute(sSQL)
-
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!
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 : - sSQL = "UPDATE [tbl_Inbond_staging] " _
-
& "SET [FileDT]=#%FD#;"
-
sSQL = Replace(sSQL, "%FD", Format(FileDateTime(sXlx) _
-
, "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 : - Dim dbVar As DAO.Database
-
-
Set dbVar = CurrentDb()
-
Call dbVar.Execute(...)
-
...
-
Call dbVar.Execute(...)
-
...
-
etc.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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
|
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?
|
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.
|
by: konaravikumar |
last post by:
writing a query to get the second highest value in atable by using select statement
| |
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)
{
|
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
|
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))
{
|
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'...
|
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,...
|
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...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |