Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Built-in Functions _ Dlookup Adds A Question Mark

Posted by: andywal6 Oct 12 2019, 03:16 AM

Hi Al

I'm using the code below to check if a Folder exists, and if not, create one, but for some reason the DLookup adds a '?' to the beginning of the result.

CODE
Debug.Print DLookup("[FoldersLocation]", "Company")
    If Dir(DLookup("[FoldersLocation]", "Company") & "\" & Forms![HostData]![HostID], vbDirectory) = "" Then
    MkDir (DLookup("[FoldersLocation]", "Company") & "\" & Forms![HostData]![HostID])
    End If


The 'IF Dir' line causes an error which says " Bad File name or number "
I put the Debug line to check and its result is:

?C:\UKGuardiansDB\HostFolders

Which is correct except for the question mark in front which incidentally, is not in that table field .
The [HostID] comes up with the correct result

Any thoughts would be appreciated.

Andy.......

Posted by: arnelgp Oct 12 2019, 04:12 AM

just maybe there are non-printable characters in your FolderLocation field.
try deleting the record and type again the location in that field.

Posted by: andywal6 Oct 12 2019, 04:49 AM

Hi arnelgp

Many thanks for your observation, you were quite correct.

This come from being lazy and copying the address from the folders Properties.

Best regards
Andy.......