SQL delete code

What would the VBA code be to delete a specific record from a table?

Something like:

Delete * from tblName where Client= me.txtclientID

??
SteveL13Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
you need to use ADO object library, apparently an ADODB.Connection object, and then use it to connect to your database with a valid connection string, and then using this object's Execute method to execute the Delete SQL statement you wish to be executed.
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
SteveL13Author Commented:
Sorry.  Not following.  Do not know how to write the code.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Rey Obrero (Capricorn1)Commented:
try this

if clientid is Number

currentdb.execute "delete * from tblName where Client=" &  me.txtclientID


if clientid is Text

currentdb.execute "delete * from tblName where Client='" &  me.txtclientID & "'"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
Here is my query designer SQL:

DELETE tblClient.*, tblClient.ClientID
FROM tblClient
WHERE (((tblClient.ClientID)=[Forms]![frmClients]![txtClientID]));

How do I convert that to VBA code?
SteveL13Author Commented:
Rey,

Thank you.  You posted the solution just as I was posting my last reply.

It is number and your solution worked perfectly.  I wish there was a guide somewhere to assist in writing simple SQL code like this.
PatHartmanCommented:
@Ryan,
The default library for Access is DAO not ADO.  DAO is optimized for working with Jet/ACE so there is no reason to use ADO.  As for other RDBMS', I haven't seen any analysis comparing DAO and ADO using the ACE library so I can't say which is better.  All the analysis that I find is for Jet and Jet has been gone since 2007.
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
>>The default library for Access is DAO not ADO
Ok, not aware this was in Access TA.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.