docmd.runsql will not work

  • Thread starter Thread starter kallen via AccessMonster.com
  • Start date Start date
K

kallen via AccessMonster.com

I am workin in Access 2007 and have the following code:

DoCmd.RunSQL "INSERT into [tbllocalformula] ( lot_no, oiltype, material_desc )
Values ([vardescript], [varoiltype], 'hello')", 0

I try to set the vardescript, etc to any value, and when I run the code on
the form, it still asks for the value. The only one that enters any data
into the table is the 'hello'.

What exactly am I doing wrong?

The vardescript and varoiltype are values that are taken from two text boxes
on the form.

Best Regards,

Kevin
 
I am workin in Access 2007 and have the following code:

DoCmd.RunSQL "INSERT into [tbllocalformula] ( lot_no, oiltype, material_desc )
Values ([vardescript], [varoiltype], 'hello')", 0

I try to set the vardescript, etc to any value, and when I run the code on
the form, it still asks for the value. The only one that enters any data
into the table is the 'hello'.

What exactly am I doing wrong?

The vardescript and varoiltype are values that are taken from two text boxes
on the form.

Best Regards,

Kevin

You had a ; in the subquery. That means end of statement. Also, do not bracket
your subquery with [ ]. as Access does this by itself.

SELECT Q.SS,
Q.AssignmentEndDate,
Employees.QuitReason,
Employees_1.[Employee Name]
FROM (Employees
RIGHT JOIN (SELECT A.Post AS Post,
A.AssignmentEndDate,
A.AssignedEmployeeSS AS SS
FROM Assignments AS A) AS Q
ON (Employees.EndDate = Q.AssignmentEndDate)
AND (Employees.SS = Q.SS))
INNER JOIN Employees AS Employees_1
ON Q.SS = Employees_1.SS
WHERE (((Q.Post) = '" & cmbPost.Value & "')
AND ((Q.AssignmentEndDate) IS NOT NULL))
 
Try:

DoCmd.RunSQL "INSERT into [tbllocalformula] ( lot_no, oiltype,
material_desc )
Values ('" & [vardescript] & "','" & [varoiltype] & "', 'hello')", 0
 
Thanks George,

I will try that one.


George said:
Try:

DoCmd.RunSQL "INSERT into [tbllocalformula] ( lot_no, oiltype,
material_desc )
Values ('" & [vardescript] & "','" & [varoiltype] & "', 'hello')", 0
I am workin in Access 2007 and have the following code:
[quoted text clipped - 15 lines]
 
Back
Top