473,382 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Cannot Get Code Right To Insert From Form

intelligen
Hi All,

I have been struggling with this for two days now...........

I have variables made up to test data for all values to go in to a table (TAuditLog) which is an all Text fields table. All of the variables are verified OK via MsgBox (and appear correctly as they will / should go into the table.)

I keep getting the error 3134 (which refers me to the DoCmd line) but that is the only indicator I get.

I think it is a simple syntax error but have searched for examples here and on the web, and this code is the closest yet.

Note: the variables not hard coded here come from captions in the form.

Dim SQL As String

TempEmpName = "BLOGGS"
TransactionKeyText = DateText.Caption & TimeStartedText.Caption
StandardText = "Still Running"

SQL1 = "INSERT INTO TAuditLog ([strEmpName], [strDepartment], [strTransactionKey], [strDate], [strTimeStart], [strTimeStop], [strDuration)]"
SQL2 = " VALUES ('" & TempEmpName & "', '" & DepartmentText.Caption & "', '" & TransactionKeyText & "', "
SQL3 = "'" & DateText.Caption & "', '" & TimeStartedText.Caption & "', '" & StandardText & "', '" & StandardText & "')"

SQLDo = SQL1 & SQL2 & SQL3
'Confirm string before insert to table
MsgBox SQLDo

DoCmd.RunSQL SQLDo

Any help gratefully appreciated. This is driving me nuts!!

Thanks,
John B
Oct 7 '06 #1
1 1528
PEB
1,418 Expert 1GB
Hi John,

There is really a fault:
change this line to:

SQL1 = "INSERT INTO TAuditLog ([strEmpName], [strDepartment], [strTransactionKey], [strDate], [strTimeStart], [strTimeStop], [strDuration])"

And:


SQL3 = "'" & DateText.Caption & "', '" & TimeStartedText.Caption & "', '" & StandardText & "', '" & StandardText & "');"

:)

Hi All,

I have been struggling with this for two days now...........

I have variables made up to test data for all values to go in to a table (TAuditLog) which is an all Text fields table. All of the variables are verified OK via MsgBox (and appear correctly as they will / should go into the table.)

I keep getting the error 3134 (which refers me to the DoCmd line) but that is the only indicator I get.

I think it is a simple syntax error but have searched for examples here and on the web, and this code is the closest yet.

Note: the variables not hard coded here come from captions in the form.

Dim SQL As String

TempEmpName = "BLOGGS"
TransactionKeyText = DateText.Caption & TimeStartedText.Caption
StandardText = "Still Running"

SQL1 = "INSERT INTO TAuditLog ([strEmpName], [strDepartment], [strTransactionKey], [strDate], [strTimeStart], [strTimeStop], [strDuration)]"
SQL2 = " VALUES ('" & TempEmpName & "', '" & DepartmentText.Caption & "', '" & TransactionKeyText & "', "
SQL3 = "'" & DateText.Caption & "', '" & TimeStartedText.Caption & "', '" & StandardText & "', '" & StandardText & "')"

SQLDo = SQL1 & SQL2 & SQL3
'Confirm string before insert to table
MsgBox SQLDo

DoCmd.RunSQL SQLDo

Any help gratefully appreciated. This is driving me nuts!!

Thanks,
John B
Oct 8 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jack | last post by:
Hi, I got a simple form where one needs to input data. The data is being processed in an asp page. However, I cannot figure out why couple of values I am typing in the form is not being retrived...
7
by: NetCoder | last post by:
Hi to all, I have made a script that uses both JavaScript and PHP. The script has a form and when it is submitted, a JavaScript confirmation box appears, asking the user to confirm their action....
2
by: John Tyce | last post by:
When a button is clicked, a date is inserted or added into a combo box like this : ComboBox.Items.Add(string) or ComboBox.Items.Insert(0,string); Either way, the new string does not show up in the...
1
by: Neo Geshel | last post by:
I am having conflicting results with two pieces of identical code. One is an insert, the other is an update to a db. The first code, which works, is this: Sub Add3_Click(sender As Object, e As...
18
by: Pedro Pinto | last post by:
Hi there once more........ Instead of showing all the code my problem is simple. I've tried to create this function: char temp(char *string){ alterString(string); return string;
6
mmarif4u
by: mmarif4u | last post by:
Hi everyone. i make a page that a user input thier icnumber with confirm ic number, it saves the data to mysql db with current date and a random access code generated automatically, NOW i have...
5
by: Ferasse | last post by:
Hi, I'm an occasional Ms-Access developer, so there is still a lot of stuff that I don't get... Right now, I'm working on a database that stores contractual information. One of the form that...
1
by: rdsandy | last post by:
Hi, I have a table Risk, a table Mitigation and a table RiskArchive. I am taking the RiskID, Criticality and MitigationPlan fields from Risk, and MitigationActionID from Mitigation and inserting...
3
by: pinko1204 | last post by:
My Update function cannot successful update to sql table even don't have any error. Please help to check .....thx PHP1 <?php require_once 'header.php'; ?> <style type="text/css"> <!--
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
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$) { } ...
0
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...
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.