Wild character in VBA

22strider

Active Member
Joined
Jun 11, 2007
Messages
311
Hello Friends


I am trying to search a table using wild character (*) and then delete it. Following is the command that I am using. I can't get the syntax right for the wild character. Could you please look at the following code and correct me?

DoCmd.DeleteObject acTable, "*" & "ImportError" & "*"

Thanks
Rajesh
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Here's the code you need to delete the Import Errors table(s):
Code:
    Dim z As Integer
    Dim db As DAO.Database
    
    Set db = CurrentDb
    For z = db.TableDefs.Count-1 To 0 Step -1
        If InStr(1, db.tblDefs(z).Name, "ImportError") > 0 Then
            DoCmd.DeleteObject acTable, db.TableDefs(z).Name
        End If
    Next z
 
Upvote 0
Thanks; I am new to learning VBA. And I was trying to make it work with DoCmd in a small procedure. You would think it should work if wild character (*) is used with right format.
 
Upvote 0
Using "*" & "ImportError" & "*" you are looking for a table named "*ImportError*", literally a table with two asterisks in the name. Access is fairly permissive in things that will cause you trouble like that.

hth,

Rich
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,123
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top