Run-time errpr '3134':
Sytanx error in INSERT INTO statement.
I don't see what I am doing wrong. Thank you for helping in advance. -
lblUsername.Caption = fOSUserName
-
-
strTable = "tblUserLog"
-
strColumns = "(Username, Time)"
-
strValues = "('" & lblUsername.Caption & "', '" & Time() & "')"
-
-
strSQL = "INSERT INTO " & strTable & " " & strColumns & " VALUES " & strValues & ";"
-
-
DoCmd.RunSQL strSQL
-
Looks like you lost the single quotes surrounding the Time() function and your label caption.
You should have -
strSQL = "INSERT INTO tblUserLog (Username,Time1) VALUES ('" & lblUsername.Caption & "','" & Time() & "')"
-
7 1347
Try this ...
strSQL = "INSERT INTO tblUserLog (Username,Time) VALUES ('" & lblUsername.Caption & "'," & Time() & ")"
The messy stuff about single and double quotes and strings inside sql strings is a source of huge confusion to me, too! I think making more substrings has made your Insert statement even more difficult to unravel.
Time is a reserved word in access. It is a function. So if you use it as a field Name, you must enclose it between square brackets. [Time]
It would be much safer to use a different name to avoid confusion. LogTime... maybe.
Juilet,
That didn't work either. There are 3 columns in the table: UserID, Username, Time. Does that change anything?
I changed Time to Time1 and now I am getting:
Syntax error (missing operator) in query expression '1:31:20 PM'. -
strSQL = "INSERT INTO tblUserLog (Username,Time1) VALUES (" & lblUsername.Caption & "," & Time() & ")"
-
-
DoCmd.RunSQL strSQL
-
Looks like you lost the single quotes surrounding the Time() function and your label caption.
You should have -
strSQL = "INSERT INTO tblUserLog (Username,Time1) VALUES ('" & lblUsername.Caption & "','" & Time() & "')"
-
The number of fields won't make any difference as long as the bit in brackets ... (Username,Time1) ... has the same number of fields in the same order as the stuff in the VALUES brackets, (and of course UserName and Time1 must be names of fields in the table)
If Time() is a date/time function you could try
strSQL = "INSERT INTO tblUserLog (Username,Time1) VALUES ('" & lblUsername.Caption & "',#" & Time() & "#)"
It's getting late and I'm well into my bottle of wine: I'll look in the morning and definitely sort this one out if someone else hasn't overnight.
Good luck!
You might try: -
Dim strSQL$
-
strSQL = "INSERT " & vbCrLf & _
-
" INTO tblUserLog (Username,Time1)" & vbCrLf & _
-
" VALUES('" & lblUsername.Caption & "', " & _
-
"#" & CDate(Time()) & "#)"
-
-
DoCmd.RunSQL strSQL
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Yesurbius |
last post by:
I am receiving the following error when attempting to run my query. In my mind - this error should not be happening - its a straight-forward query with a subquery. I am using Access 2003 with all...
|
by: rolltide |
last post by:
I've seen many similar threads, but despite repeated efforts I cannot figure out my problem. I am running Access 2003, VB 6.5, Office XP Pro. Code excerpt is below (you can see where I've tried...
|
by: GLEberts |
last post by:
I can not seem to get rid of this syntax error - hope someone can help out.
the error I am getting is:
Run time Error 3075
Syntax error missing operator in query expression
=name
I have...
|
by: guillermobytes |
last post by:
Hi,
i'm making a query with PDO and there is a SQL syntax error in it.
$sql = 'BAD CODE';
$pdoStmt = $pdo->prepare($sql);
if (false === $pdoStmt) {
echo 'ERROR';
}
|
by: erone |
last post by:
Hello, good morning.
I have a syntax error here. Can you help? Thanks. It's a Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
on the "echo" line :
<?
$sql = "SELECT addrid,...
|
by: Bauklotz |
last post by:
So, recently I've been experimenting with a telnet server, and a 5250 terminal emutator and I thought of making a field system, for easier graphical (well, not quite) displaying.
This basically...
|
by: brkseven |
last post by:
Looking for help with this Contact Form.
The error is on line 1, but that' doesn't mean a lot, I think. In fact, a php syntax check passed it, but I was hoping for an easy syntax error, it looks...
|
by: Topbidder |
last post by:
I have this error on the code
Parse error: syntax error, unexpected '"' in /home/topbidd/public_html/bid2/bid_classic.php on line 159
now i thought the error was this
It seems that the...
|
by: CYNTHIA CUTRER |
last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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: 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,...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |