Need help using Docmd.RunSql

  • Thread starter Thread starter Dustin
  • Start date Start date
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
 
Hi,
If PlayerList.ID is numeric, then you don't need to delimit
with single quotes. Remove them and try it out
 
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


.
 
Back
Top