Hello friends,
I'm trying to run this Dynamic SQL in VB, but I keep getting "Compile Error" Syntax Error, in the "Bolded" area. I'm only trying to change these fields for the second query listed, should I remove the first, and repeat steps? The reason why I'm doing this, is because the table name changes from month to month. What do you Guru's recommend?
Private Sub Command0_Click( )
' Declare DAO
Dim qdfCurr As DAO.QueryDef
' Declare String Name
Dim strSQL As String
' Generation of SQL Code strSQL = "SELECT dbo_" & Format(Date, "mmm") & Format(Date, "yy").id, dbo_" & Format(Date, "mmm") & Format(Date, "yy").prior ity, dbo_" & Format(Date, "mmm") & Format(Date, "yy").clss, dbo_" & Format(Date, "mmm") & Format(Date, "yy").ky, dbo_" & Format(Date, "mmm") & Format(Date, "yy").date, dbo_" & Format(Date, "mmm") & Format(Date, "yy").code, FROM dbo_" & Format(Date, "mmm") & Format(Date, "yy")
' Query Definitions will be sent to "MyQuery"
Set qdfCurr = CurrentDb.Query Defs("Current_M onth_Date")
Set qdfCurr = CurrentDb.Query Defs("Get_Repor t60")
' The query definitions are equal to the String with the stored SQL
qdfCurr.SQL = strSQL
End Sub
2 1463
Hello friends,
I'm trying to run this Dynamic SQL in VB, but I keep getting "Compile Error" Syntax Error, in the "Bolded" area. I'm only trying to change these fields for the second query listed, should I remove the first, and repeat steps? The reason why I'm doing this, is because the table name changes from month to month. What do you Guru's recommend?
Private Sub Command0_Click( )
' Declare DAO
Dim qdfCurr As DAO.QueryDef
' Declare String Name
Dim strSQL As String
' Generation of SQL Code strSQL = "SELECT dbo_" & Format(Date, "mmm") & Format(Date, "yy").id, dbo_" & Format(Date, "mmm") & Format(Date, "yy").prior ity, dbo_" & Format(Date, "mmm") & Format(Date, "yy").clss, dbo_" & Format(Date, "mmm") & Format(Date, "yy").ky, dbo_" & Format(Date, "mmm") & Format(Date, "yy").date, dbo_" & Format(Date, "mmm") & Format(Date, "yy").code, FROM dbo_" & Format(Date, "mmm") & Format(Date, "yy")
' Query Definitions will be sent to "MyQuery"
Set qdfCurr = CurrentDb.Query Defs("Current_M onth_Date")
Set qdfCurr = CurrentDb.Query Defs("Get_Repor t60")
' The query definitions are equal to the String with the stored SQL
qdfCurr.SQL = strSQL
End Sub
matrekz42
Try this:
Format(Date()," mmm") & "" & Format(Date()," yy")
Hello friends,
I'm trying to run this Dynamic SQL in VB, but I keep getting "Compile Error" Syntax Error, in the "Bolded" area. I'm only trying to change these fields for the second query listed, should I remove the first, and repeat steps? The reason why I'm doing this, is because the table name changes from month to month. What do you Guru's recommend?
Private Sub Command0_Click( )
' Declare DAO
Dim qdfCurr As DAO.QueryDef
' Declare String Name
Dim strSQL As String
' Generation of SQL Code strSQL = "SELECT dbo_" & Format(Date, "mmm") & Format(Date, "yy").id, dbo_" & Format(Date, "mmm") & Format(Date, "yy").prior ity, dbo_" & Format(Date, "mmm") & Format(Date, "yy").clss, dbo_" & Format(Date, "mmm") & Format(Date, "yy").ky, dbo_" & Format(Date, "mmm") & Format(Date, "yy").date, dbo_" & Format(Date, "mmm") & Format(Date, "yy").code, FROM dbo_" & Format(Date, "mmm") & Format(Date, "yy")
' Query Definitions will be sent to "MyQuery"
Set qdfCurr = CurrentDb.Query Defs("Current_M onth_Date")
Set qdfCurr = CurrentDb.Query Defs("Get_Repor t60")
' The query definitions are equal to the String with the stored SQL
qdfCurr.SQL = strSQL
End Sub
Try knocking out double quotes for the date format values and substitute 'mmm' instead of "mmm", and similarly 'yy' instead of "yy".
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Martin Feuersteiner |
last post by:
Hi! I would be grateful for any advise regarding what I'm doing wrong.. My
brain is stuck. Probably some stupid simple mistake I don't see. Thanks very
much for your efforts!
Martin
I have this code:
DECLARE
@ContactID varchar(10),
|
by: Michael Dekson |
last post by:
Hello,
Can I exe file made in Microsoft Visual C++ decompile into source code.
If it is possibly please tell me how.
Thanks
|
by: Jason |
last post by:
Hi,
I was wondering if any could point me to an example or give me ideas on how
to dynamically create a form based on a database table? So, I would have a
table designed to tell my application to create certain textboxes, labels,
and combo boxes? Any ideas would be appreciated.
Thanks
|
by: John |
last post by:
Hi all,
I need finality on this once and for all please.
I have a main page which contains a couple of placeholders and within these
placeholders, depending on what the user presses, I load different user
controls. This loading of user controls is done within the code-behind of
the main page. The problem is that before loading a user control in place of
another, I need to do a Controls.Add then a Controls.Remove so the viewstate
is...
|
by: 63q2o4i02 |
last post by:
Hi, I've been thinking about Python vs. Lisp. I've been learning
Python the past few months and like it very much. A few years ago I
had an AI class where we had to use Lisp, and I absolutely hated it,
having learned C++ a few years prior. They didn't teach Lisp at all
and instead expected us to learn on our own. I wasn't aware I had to
uproot my thought process to "get" it and wound up feeling like a
moron.
In learning Python I've...
| |
by: Y2J |
last post by:
I am working through this book on C++ programming, the author is
speaking of using linked lists. He gave and example which I found
confusing to say the least. So I rewrote the example in a way that I
could better understand the concept, he was trying to convey to me.
I ran my own example and it crashed and burn "what a surprise!" : (. I
ran the authors example out of the book and quess what, it crashed
also, : 0. I ran them both on my...
|
by: Dip |
last post by:
Hello Experts,
Here is the code to flatten a PC hierarchy into a level based table. It
works fine.
SELECT
t1.TASK_ID AS TASK_LV1,
t2.TASK_ID AS TASK_LV2,
t3.TASK_ID AS TASK_LV3,
t4.TASK_ID AS TASK_LV4,
t5.TASK_ID AS TASK_LV5
FROM dbo.Project t1 LEFT OUTER JOIN
|
by: Mike Collins |
last post by:
I have a form where I create dynamic controls at runtime. With this, I am
adding a dynamic required field validator to each control as needed, but the
validators are not firing when I click submit. The submit button was placed
at design time and its causesvalidation property is set to true. Can someone
tell me if something is missing from my code? Thank you.
1. Code to add dynamic control works fine and I get the Id of the textbox...
|
by: |
last post by:
I'm looking for some design guidance on a collection of projects I'm working
on.
The project involves a bunch of websites constructed out of a collection of
user controls. Different user populations with different access rights and
"roles" will be visiting the site. I will be using ASP.NET 2.0's membership,
roles, and profiles stuff to manage access.
User controls need to be visible or not visible depending on user role. In
some...
|
by: Alf P. Steinbach |
last post by:
I once suggested in that SomeOne Else(TM) should propose
a string value class that accepted literals and char pointers and so on,
with possible custom deleter, and in case of literal strings just
carrying the original pointer.
In other words, for the simplest usage code:
* no overhead (just carrying a pointer or two), and
* no possibility of exceptions (for that case).
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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: 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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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
| | |