In VB, I have created an append query that will write the results to a table. To each of the records being written, I want to include the user name of the person running the query. I know how to get the user name but do not know how to insert it, even if I can, into the append query. Is this possible? I have the statement I am running now. I get an invalid syntax error now when I run it - Private Sub Command89_Click()
-
On Error GoTo Err_Command89_Click
-
-
Dim stGetUser As String
-
Dim stGetParms As String
-
-
stGetUser = GetLoginName()
-
-
stGetParms = "INSERT INTO TEST ( JOB_ID, PARAMETER_VALUE, stGetUser as User) " & _
-
"SELECT JOB_PARAMETERS.JOB_ID, JOB_PARAMETERS.PARAMETER_VALUE " & _
-
"FROM JOB_PARAMETERS " & _
-
"WHERE (((JOB_PARAMETERS.PARAMETER_NAME) = 'physicalId')) " & _
-
"GROUP BY JOB_PARAMETERS.JOB_ID, JOB_PARAMETERS.PARAMETER_VALUE"
-
DoCmd.RunSQL stGetParms
-
-
Exit_Command89_Click:
-
Exit Sub
-
-
Err_Command89_Click:
-
MsgBox Err.Description
-
Resume Exit_Command89_Click
-
-
End Sub
2 5058 ADezii 8,834
Recognized Expert Expert
In VB, I have created an append query that will write the results to a table. To each of the records being written, I want to include the user name of the person running the query. I know how to get the user name but do not know how to insert it, even if I can, into the append query. Is this possible? I have the statement I am running now. I get an invalid syntax error now when I run it
Private Sub Command89_Click ()
On Error GoTo Err_Command89_C lick
Dim stGetUser As String
Dim stGetParms As String
stGetUser = GetLoginName()
stGetParms = "INSERT INTO TEST ( JOB_ID, PARAMETER_VALUE , stGetUser as User) " & _
"SELECT JOB_PARAMETERS. JOB_ID, JOB_PARAMETERS. PARAMETER_VALUE " & _
"FROM JOB_PARAMETERS " & _
"WHERE (((JOB_PARAMETE RS.PARAMETER_NA ME) = 'physicalId')) " & _
"GROUP BY JOB_PARAMETERS. JOB_ID, JOB_PARAMETERS. PARAMETER_VALUE "
DoCmd.RunSQL stGetParms
Exit_Command89_ Click:
Exit Sub
Err_Command89_C lick:
MsgBox Err.Description
Resume Exit_Command89_ Click
End Sub
Let's assume you have a Field (USER_NAME) in your Table (Test) that will store the User's Name, then: -
'Dim stGetUser As String 'don't need
-
Dim stGetParms As String
-
-
'Don't need
-
'stGetUser = GetLoginName()
-
-
stGetParms = "INSERT INTO TEST ( JOB_ID, PARAMETER_VALUE, USER_NAME) " & _
-
"SELECT JOB_PARAMETERS.JOB_ID, JOB_PARAMETERS.PARAMETER_VALUE, GetLoginName() As QUser " & _
-
"FROM JOB_PARAMETERS " & _
-
"WHERE (((JOB_PARAMETERS.PARAMETER_NAME) = 'physicalId')) " & _
-
"GROUP BY JOB_PARAMETERS.JOB_ID, JOB_PARAMETERS.PARAMETER_VALUE"
-
DoCmd.RunSQL stGetParms
NeoPa 32,573
Recognized Expert Moderator MVP
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use the tags in future.
ADMIN.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sans Spam |
last post by:
Greetings! I have a table that contains all of the function
permissions within a given application. These functions are different
sections of a site and each has its own permissions (READ, WRITE,
UPDATE, DELETE) which are controlled by a web frontend and the table
records are manipulated to control the permissions.
Example:
The Press Release section record would look like this:
Username: John Doe
Function Name: Press Release
|
by: shank |
last post by:
I'm trying to insert a customer profile with a stored procedure. This same
code has worked on other sites. But on this site, it appears to be ignored.
Nothing happens. The page loads fine with all the Request objects being
filled. The Insert code does nothing. I changed stp_InsertClient to
stp_xInsertClient just to see what happens. No errors, page loads, Request
objects are filled. All other ASP pages load fine. I setup the same code in...
|
by: ImraneA |
last post by:
Hi there
I had pleasure of upsizing Access v97 db to Access v2K/SQL 2K.
Wish to provide some knowledge gained back to community - hopefully
help others.
1.Question how do you test stored procedure from SQL Server vs MS
Access point of view ?
|
by: celineusa |
last post by:
Hello!
Here is part of my database:
tblStudents: StudentID
tblMajorsAndStudents: StudentID, MajorID
tblMajors: MajorID
tblMajorsAndClasses: MajorID, ClassID, QuarterTaken
tblClasses: ClassID
tblStudentsAndClasses: StudentID, ClassID
|
by: Bob |
last post by:
Hi all,
I'm trying to import data, modify the data then insert it into a new
table. The code below works fine for it but it takes a really long
time for 15,000 odd records. Is there a way I can speed up the
processing substantially? as it currently takes about 10 minutes and
thats just way too long because there is many of these imports that I
need to do.... I currently insert each record one by one and I
imagine
thats where all the...
| |
by: ak1dnar |
last post by:
There is a Error getting while i am entering records using this jsp file.
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="../Connections/conn.jsp" %>
<%
// *** Edit Operations: declare variables
// set the form action variable
String MM_editAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) {
|
by: Chuck |
last post by:
Can the SQL code from an Append query be inserted into the form module?
The form module currently has a DoCmd Run Macro statement.
The Macro opens the Append query which runs correctly.
I'm trying to eliminate the DoCmd in the form code and the referenced Macro.
SQL code:
INSERT INTO tblWT1 ( Mfg, Series, Model, Config, Options )
SELECT tblMain.Mfg, tblMain.Series, tblMain.Model, tblMain.Config, _
tblMain.Options
FROM tblMain
|
by: Minion |
last post by:
I hate to even post this message as I probably know the answer before I begin. Still there are several problems facing me with this particular challenge.
First though I'll goto into the overview of the problem. I need to create an append query to move the values of one table to another for monthly backups. This is not hard as I have already created an Append Query. The problem is that the table name changes monthly (destination name that is)...
|
by: franc sutherland |
last post by:
Hello,
I am using Access 2003.
Is it possible to use string variables in the INSERT INTO statement?
I am using the INSERT INTO statement to add a long list of contacts to
a group by looping through the recordset (based on a linked
spreadsheet, 'tbl_group_import') and using the INSERT INTO statement
on each loop. I am using the rst.Fields.Item("FieldName") method to
|
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: 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: 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: 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: 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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |