It appears that this is not directly possible from within MSAccess. You can mark the records for deletion... you can even set a flag in the local registry for MSAccess to ignore the marked records; however, there doesn't appear to be anyway to issue the
PACK
command from within VBA or ODBC.
I'll take another walk thru the internet to see if something pops up... would be helpful to know what OS and version of Office/Access/FoxPro you are using.
[Update]
Option 1:
If you have the
VfpOleDB.dll (MS link for v9) - Dim cn As ADODB.Connection
-
Dim strPath as String
-
strPath = "your file's path"
-
Set cn = New ADODB.Connection
-
cn.Open ("Provider=vfpoledb.1;Data Source= strPath")
-
'
-
With cn
-
If .STATE = adStateOpen Then .Close
-
.Open
-
.Execute "PACK name_of_database.dbf"
-
End With
-
cn.Close
-
Set cn = Nothing
Option 2:
This is a VB workaround. Often VB can be modified to work within the VBA environment.
Unfortunately I do not have a FoxPro installation to check the functionality of the following:
Support-Microsoft:How to ZAP or PACK a dBASE or FoxPro Table
The workaround requires an INI setting be made and then either uses a copy of at template file and the insert method or creates a temporary table, moves the good records, deletes the current table, renames the temporary table, finally refreshes the linked tables. I don't know how that will work in VBA and FoxPro.