I am trying to log my users action into a back-end table if a employee master data is change. Below is my code but i am getting an error with inserting a date. - Dim strSQL As String
-
-
strSQL = "INSERT INTO TblMasterBackEnd " & _
-
"( HRAPSNO, AlphaCode, FirstName, LastName, " & _
-
"Branch, Dept, Loc, CostCtr, Netuser, " & _
-
"DateModified, DateStarted, PayRate, " & _
-
"AnnualSalary, BirthDate, Sex, MaritalStatus, " & _
-
"Dep, Position, DateCreated) " & _
-
"VALUES ('" & Me.txtHRAPSNo & "', '" & _
-
Me.txtAlphaCode & "','" & Me.txtFirstName & "','" & _
-
Me.txtLastName & "','" & Me.txtBranch & "','" & _
-
Me.txtDept & "', '" & Me.txtLoc & "', '" & _
-
Me.txtCostCtr & "', '" & Me.txtNetUser & "', #" & _
-
Me.txtDateModified & "#, #" & Me.txtDateStarted & "#, " & _
-
Me.txtPayRate & ", " & Me.txtAnnualSalary & ", #" & _
-
Me.txtBirthDate & "# ,'" & Me.cboSex & "', '" & _
-
Me.cboMaritalStatus & "'," & Me.txtDep & ",'" & _
-
Me.txtPosition & "', #" & Me.txtDatecreated & "# );"
-
-
DoCmd.RunSQL (strSQL)
-
DoCmd.Save
-
Me.Requery
3 1625
Adict,
First, please use the code tags when posting code, which is a rquirement of this forum. I have edited your post to reflect this. Also, concerning this, it is also wise to add line continuation marks on the forum so that users can view your code more easily, without scrolling all the way to the right.
Second, is this a direct cut and paste from your VBA editor? I have made some minor adjustments to the spacing of your code, but since I am not sure this was a direct cut and paste, I cannot say that this would solve anything. On the surface, I don't see anything that pos out concerning your dates.
Third, when you have trouble with SQL statements, it is often useful to have teh code print it to your Immediate Window so you can see exactly what your SQL statement contains before you execute it. Just add the statement Debug.Print strSQL to the line just prior to running your SQL statement (in this case, line 19).
Fourth, if you are inserting all these fields into a table (and it appears these values are currently on a form, is there a particular reason this form is not bound to TblMasterBackEnd ? There may be a good reason for this, but it would be good to know.
Fifth, an alternate method (and one that I prefer) is to use a Recordset where you are directly updating the table--this is all preference, but for me, it allows me to more directly see what I am updating.
Sixth, you say you are getting an error with inserting a date. How do you know? What error are you getting and how do you know it is related to the date? This information will help us understand the nature ofyour problem.
Seventh, on the surface, it appears that you are creating redundant data in your Database, which most of us try to avoid unless it is absolutelye necessary. Based on the data listed, I don't see any fields that would much change over time, other than pay rate. Why not just add the index for the employee into the table and only the data that needs to be saved? Again, there could be a good reason for you saving so much information redundantly, but it would be good to know the reasons.
Thanks!
Thanks twinnyfo and Neopa. I have used recordset and achieved the results. The reason why i want a redundant data is to ensure that every data changes users make on the main master file. This is to achieve audit trails for master data.
Thanks much
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Khurram |
last post by:
I have a problem while inserting time value in the datetime Field.
I want to Insert only time value in this format (08:15:39) into the SQL
Date time Field.
I tried to many ways, I can extract...
|
by: abcabcabc |
last post by:
I write an application which can let user define own date format to input,
How to convert the date string to date value with end-user defined date
format?
Example, User Defined Date Format as...
|
by: Richiep |
last post by:
I am trying to get a UK format date of dd/mm/yyyy.
Why does the following subroutine not return a valid date in a web form?
The date returned is #12:00:00 AM# but the date I entered into the...
|
by: gazelle04 |
last post by:
I'm trying to enter the current date into the table through code but there's an error in inserting the date.
Whats wrong with this code:
strSQL = "INSERT INTO University (, , )"
strSQL =...
|
by: Paul |
last post by:
I'm sure this isn't a difficult question, but I've been struggling trying to
insert the current date into a sql server field. I've tried numerous
suggestions that I've seen in newsgroups and...
|
by: markjerz |
last post by:
Hi,
I basically have two tables with the same structure. One is an archive
of the other (backup). I want to essentially insert the data in to the
other.
I use:
INSERT INTO table ( column,...
|
by: Nathan Sokalski |
last post by:
When determining whether a String can be converted to a DateTime, you can
use the IsDate() method. However, I would also like to know whether the
string is a date, a time, or both a date and a...
|
by: vp.softverm |
last post by:
hi all .
Am facing problem with the date picker. when i click on date picker in
a popup window. the date table is opened in the middle of the pop up
window.
and it is unable to scroll with...
|
by: haridharmajan |
last post by:
I Need to add multiple date into a field using calender each date is to be separated by comma ie when I click on the show month it must display calender and when I click on a date it must inser it to...
|
by: mmclancy |
last post by:
I'm using Oracle's SQL Developer to do the following:
CREATE TABLE Account (
AccountID INT NOT NULL,
CreditID INT NOT NULL,
CardType VARCHAR(15) NOT NULL,
ExpiryDate DATE,
PRIMARY KEY...
|
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: 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: 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: 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...
|
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: 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...
| |