|
-
Apr 9th, 2004, 10:51 PM
#1
Thread Starter
Lively Member
INSERT INTO - Problem with SQL Statement ?
I am using a form, that when a button is pressed, must use an INSERT INTO statement.
The form has its own related table (called Task), which is passed into a recordset (rsTask), but it must use the INSERT INTO to insert 2 values into fields in a different table called Employee.
The idea is that if the Employee completes a certain number of tasks, then they are moved up a grade (at least, according to the system they are).
The code I have used for the button is as follows:
Code:
Dim Taskrs As Recordset
Set Taskrs = New ADODB.Recordset
Set Taskrs = db.Execute("SELECT EmpID From TASK WHERE TASK.EmpID='" & txtEmpID & "'")
Dim sqlSeniorEmployee
Dim sqlStandardEmployee
Dim sqlNew Employee
sqlSeniorEmployee = "INSERT INTO Emp(EmpTitle, EmpGrade) VALUES('Senior_Employee', 'Grade_3') WHERE EMP.EmpID = '" & txtEmpID & "'"
sqlStandardEmployee = "INSERT INTO Emp(EmpTitle, EmpGrade) VALUES('Standard_Employee', 'Grade_2') WHERE EMP.EmpID = '" & txtEmpID & "'"
sqlNewEmployee = "INSERT INTO Emp(EmpTitle, EmpGrade) VALUES('New_Employee', 'Grade_1)' WHERE EMP.EmpID = '" & txtEmpID & "'"
While Taskrs.RecordCount >= 100
db.Execute sqlSeniorEmployee
Wend
While Taskrs.RecordCount >= 25
db.Execute sqlStandardEmployee
Wend
While Taskrs.RecordCount <= 10
db.Execute sqlNewEmployee
Wend
End Sub
However, when I press the button with this code I get this error:
Run-time error '-2147217900 (80040e14)':
Missing semicolon ( ; ) at end of SQL statement
To me the SQL statement looks correct, I don't think it has anything to do with a semicolon at all, but am I missing something or constructing it wrongly?
Also when the INSERT INTO has been performed I would also like to return the updated value of the field to a textbox called txtUpdatedValue on this form, but I'm not sure how...
Can anyone please help with these probs?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|