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 5031
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
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,556
Expert Mod 16PB
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,...
|
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...
|
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...
|
by: celineusa |
last post by:
Hello!
Here is part of my database:
tblStudents: StudentID
tblMajorsAndStudents: StudentID, MajorID
tblMajors: MajorID
tblMajorsAndClasses: MajorID, ClassID, QuarterTaken
tblClasses:...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have 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...
| |