Deleting recors in a linked table

  • Thread starter quinto via AccessMonster.com
  • Start date
Q

quinto via AccessMonster.com

When I try to run a query to delete records in a link txt table I get the
following message: Deleting data in a link table is not supported by this
ISAM.
Is there a way around this?
Can I delete records in a txt link table? and how can I do it?

Thanks
Quinto
 
C

ceesdatabase

Hello Quinto,

One way to do this is by the function below, but take in mind that your
original file
wil be overwritten and you could expand the function with some code that
copies
your original file. TRY THIS function first with a dummy file !!!

When I runned the function multiple times on the same file, this file was
damaged at the end for unknown reasons. Let me know if you have the same
problems.

grtz

***********************************************************
Function deleteLinesInTextFileForQuinto(file As String, criterium As String)
Dim fs, f, fTemp As Object
Dim ln As String
Dim tempFile As String

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

On Error GoTo Error_deleteLinesInTextFileForQuinto

tempFile = Replace(file, ".txt", "_temp.txt")

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(file, ForReading) 'your text file
Set fTemp = fs.CreateTextFile(tempFile, ForWriting, True) 'temporary text file

Do Until f.AtEndOfStream
ln = f.ReadLine
If ln Like "*" & criterium & "*" Then
'skip
Else
fTemp.WriteLine ln
End If
Loop

f.Close
fTemp.Close

fs.CopyFile tempFile, file, True
fs.DeleteFile tempFile

Exit Function

Error_deleteLinesInTextFileForQuinto:

MsgBox ("Error " & Err & "(" & Err.Description & ") has occurred in
procedure <deleteLinesInTextFileForQuinto> !"), vbCritical

End Function

**********************************************************
 
Q

quinto via AccessMonster.com

I am unable to get to work.
I changed the "your file" to the file any other changes I need to make?

Thanks
Quinto
 
C

ceesdatabase

Did you call the function like this :

deleteLinesInTextFileForQuinto "yourfile.txt", "deletecriterium"

and do you have the scrrun.dll (Microsoft Scripting Rintime) on your PC ?

grtz
 
Q

quinto via AccessMonster.com

Thank you all ,I went back to cut and past.
I was not able to apply the suggestions.
Your help is always appreciated

Quinto
Did you call the function like this :

deleteLinesInTextFileForQuinto "yourfile.txt", "deletecriterium"

and do you have the scrrun.dll (Microsoft Scripting Rintime) on your PC ?

grtz
I am unable to get to work.
I changed the "your file" to the file any other changes I need to make?
[quoted text clipped - 10 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top