Can't delete specific record data from MS Access tables using VB6

I'm using VB6 to connect to MS Access and I'm trying to delete all records from 3 baseball data tables that have a specific GameID associated with them. The GameID is typed into Text1.Text --- I can't get it to work. It doesn't throw an error, it simply ignores the code. Here's the code I have:


Dim cnn As New ADODB.Connection
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\MyDB.mdb"
cnn.Open
cnn.Execute "delete * from Batting Where GameID = " & Text1.Text
cnn.Execute "delete * from Pitching Where GameID = " & Text1.Text
cnn.Execute "delete * from BoxScores Where GameID = " & Text1.Text
cnn.Close

MsgBox ("Delete of data is complete."), vbInformation



Thanks for any assistance...
LVL 4
jazjefAsked:
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.

IrogSintaCommented:
Is the GameID field in the table a TEXT Data Type?  If so, you need to add single quotes before and after the ID like so:
cnn.Execute "delete * from Batting Where GameID = '" & Text1.Text & "'"

Open in new window

Ron

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
jazjefAuthor Commented:
Yes, the field is Short Text data type ..... I tried your code, but it doesn't have any effect.... it throws no errors, and the message box pops up---but the data remains.
jazjefAuthor Commented:
My bad.... I was doing something else wrong. Your solution works just fine IrogSinta----many thanks for the help.
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
Visual Basic Classic

From novice to tech pro — start learning today.