Packing Paradox tables which maintain referential integrity

I am using the BDE DbiDoRestructure call to pack a Paradox table.
This works fine on normal tables but gives an Access Violation message
if the table has any referential integrity settings.  I thought this
might be something to do with the function trying to access the other
table involved in the link so I made sure they were both closed but
this made no difference.  Does anybody know how to solve this....

Thanks

Kev