i have a dbf file which i linked in access and running sql query through vba but delete query only marks for deletion.is there any method to delete this record permanently as in foxpro after deletion we use pack to permanently delete a record.every time after running vba program i have to open foxpro use file and then pack to delete record permanently.
permanent delete in linked table
Collapse
X
-
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 thePACKcommand 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)
Option 2:Code: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
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.
Comment