By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,476 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,476 IT Pros & Developers. It's quick & easy.

Why does HyperlinkPart return inconsistent values?

P: n/a
This code is supposed to delete documents from local storage that are
associated with a particular record. That is, if a hyperlink to the
document exists in tblDocuments, then delete that document. But if the
document is associated with other records in the database, do not delete it.
Should be simple enough - just count the number of times the document
appears in tblDocuments and delete on the condition that it appears only
once.

lngEid = the record in question
strSql = "SELECT HyperlinkPart([Document],0) As HlkDoc FROM tblDocuments
WHERE Entity_ID = " & lngEid
Set rst = CurrentDb.OpenRecordset(strSql)
'loop through documents associated with lngEid, check each one to make sure
it's not linked to other records
Do Until rst.EOF
'this DCount statement always returns 0 - even if the hyperlink appears
multiple times in the table
intDocCt = DCount("Doc_ID", "tblDocuments", "HyperlinkPart([Document],0)
= " & rst!HlkDoc)
If intDocCt = 1 Then
strDdoc = DLookup("DocDir", "tblPrefs") & "\" & rst!HlkDoc
Set objFile = CreateObject("Scripting.FileSystemObject")
objFile.DeleteFile strDdoc
End If
rst.MoveNext
Loop

I've tried debug.print to check rst!HlkDoc - looks fine. Why does that
DCount always return 0? Are there hidden characters in HyperlinkPart? Am I
missing something, or should I maybe go about this another way?

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> I've tried debug.print to check rst!HlkDoc - looks fine. Why does that
DCount always return 0? Are there hidden characters in HyperlinkPart? Am I missing something, or should I maybe go about this another way?


good 'ol Chr(34) did the trick...

strSql = "SELECT HyperlinkPart([Document],0) As HlkDoc FROM tblDocuments
WHERE Entity_ID = " & lngEid
Set rst = CurrentDb.OpenRecordset(strSql)
Do Until rst.EOF
If DCount("Doc_ID", "tblDocuments", "HyperlinkPart([Document],0) = " &
Chr(34) & rst!HlkDoc & Chr(34)) = 1 Then
strDdoc = DLookup("DocDir", "tblPrefs") & "\" & rst!HlkDoc
Set objFile = CreateObject("Scripting.FileSystemObject")
objFile.DeleteFile strDdoc
End If
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.