Taylor814
asked on
INSERT INTO help (MS Access and VB6)
I cannot seem to get this statement to work. It throws a Syntax Error
MyConnAcct.Execute ("INSERT INTO UserAccounts ([attempts]) WHERE ID =" & Form1.curracct & " VALUES (" & Form1.LoginCounts & ")")
use this.. an Insert statement do not have a where cluase..
MyConnAcct.Execute ("INSERT INTO UserAccounts ([attempts]) " VALUES (" & Form1.LoginCounts & ")")
MyConnAcct.Execute ("INSERT INTO UserAccounts ([attempts]) " VALUES (" & Form1.LoginCounts & ")")
it should be
MyConnAcct.Execute ("INSERT INTO UserAccounts ([attempts]) VALUES (" & Form1.LoginCounts & ")")
MyConnAcct.Execute ("INSERT INTO UserAccounts ([attempts]) VALUES (" & Form1.LoginCounts & ")")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can not use the WHERE statement in the INSERT.
If you want to update the login attempts for a certain id, use the UPDATE statement, assuming
the ID exists in the table:
If you want to update the login attempts for a certain id, use the UPDATE statement, assuming
the ID exists in the table:
MyConnAcct.Execute("UPDATE UserAccounts SET [attempts]=" & Form1.LoginCounts & " WHERE ID=" & Form1.curracct)
an update and an insert statement structures differs. You asked an insert but resulted with an update statement.
"You can not use the WHERE statement in the INSERT."
Sure you can. Example:
INSERT INTO Table1 ( FIELD1 )
SELECT Table2.FIELD1
FROM Table2
WHERE (((Table2.ID)=3));
mx
Sure you can. Example:
INSERT INTO Table1 ( FIELD1 )
SELECT Table2.FIELD1
FROM Table2
WHERE (((Table2.ID)=3));
mx
DatabaseMX the where clause is not a part of the insert statement its a part of the select statement which is supplying values to the insert statement.
What I posted is an Access Append query example ... but I see what you meant by that post.
mx
mx
MyConnAcct.Execute "INSERT INTO UserAccounts ([attempts]) WHERE ID =" & Form1.curracct & " VALUES (" & Form1.LoginCounts & ")"