Need help using Docmd.RunSql

D

Dustin

I need to run an insert statement using a RUNSQL command
on the double click of a listbox. It needs to insert the
the data based on the id associated to the double clicked
record. I have read the help files and tried multiple
instances...this will actually run but won't insert any
rows.

DoCmd.RunSQL "INSERT INTO MyTeam ( PlayerID, [First],
[Last], Pos, Team ) SELECT [Player List].ID, [Player
List].First, [Player List].Last, [Player List].Pos,
[Player List].Team FROM [Player List]WHERE ((([Player
List].ID)='" & Combo0 & "'));"

An explanation of how to format the Delete action query
would also be a huge help using the same type of format
(i.e. deleting based off of the id in the listbox).

Thanks
Dustin
 
D

Dan Artuso

Hi,
If PlayerList.ID is numeric, then you don't need to delimit
with single quotes. Remove them and try it out
 
D

dustin

Thanks works great...always the little things lyou forget.
-----Original Message-----
Hi,
If PlayerList.ID is numeric, then you don't need to delimit
with single quotes. Remove them and try it out

--
HTH
Dan Artuso, Access MVP


I need to run an insert statement using a RUNSQL command
on the double click of a listbox. It needs to insert the
the data based on the id associated to the double clicked
record. I have read the help files and tried multiple
instances...this will actually run but won't insert any
rows.

DoCmd.RunSQL "INSERT INTO MyTeam ( PlayerID, [First],
[Last], Pos, Team ) SELECT [Player List].ID, [Player
List].First, [Player List].Last, [Player List].Pos,
[Player List].Team FROM [Player List]WHERE ((([Player
List].ID)='" & Combo0 & "'));"

An explanation of how to format the Delete action query
would also be a huge help using the same type of format
(i.e. deleting based off of the id in the listbox).

Thanks
Dustin


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top