Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2003
    Posts
    106

    Unanswered: Auto Expand data as user types in textbox

    Hi
    Can anyone help please?

    I have a textbox labelled filepath. The user can manually type in a file path.

    The Onchange event checks to see whether the path is valid (Dir method) and if the file is valid, it enables a commandbutton and writes the actual file 'name' in a box called filename.

    With me so far?

    What i would like to do if it is possible, is get the full path of the filename to appear in the filepath box as the user types. As the user types over the top of what is in there, the path should change to the path of the 'guessed' filename.

    I hope this makes more sense than it sounds! The closest analogy, is the Auto Expand function of a combo box.

    Thanks

    Dan

  2. #2
    Join Date
    Sep 2003
    Location
    UK
    Posts
    122
    To do this you will need to use code to create a recordset or table of directories available.

    The only other possibility would have access searching the harddrive every keystroke and often aborting the search for the next search. It'd never keep up.

    With the recordset / table of paths method you could pritty much use the autoexpand function of the combo by linking the combo and the record set.

    Another method yet not quite so comprihensive: store a list of paths the user has typed before (to a table say) and use that with auto expand this would be a little like the autofill in IE when you type an URL
    Matt the Hat says: "what!?"
    A child of five could understand this! Fetch me a child of five!
    SCARY HARD CHALLENGE: http://www.dbforums.com/showthread.php?threadid=988682

  3. #3
    Join Date
    Aug 2003
    Posts
    106

    Almost but not quite

    I get the idea and thanks for the advice but i'm sure there must be a way of doing it.

    If Access Dir's the textbox with each keystroke, it does select a file and this appears in the filename box.

    All i need to do is somehow get the path of the file that access has found, display this in the textbox and the use the sellength and seltext properties to position the cursor for the user to carry on typing.

    I almost have it but don't now how to retrieve the path...

    Dim myDir
    If Forms!EditErrorFileFrm.EditFileBox.Text = "" Then
    Forms!EditErrorFileFrm!OpenBtn.Enabled = False
    Else:
    On Error GoTo 10
    myDir = Dir("" & Forms!EditErrorFileFrm!EditFileBox.Text & "")
    If myDir <> "" Then
    Forms!EditErrorFileFrm!DirectFileBox.Caption = myDir
    Forms!EditErrorFileFrm!OpenBtn.Enabled = True
    Else:
    10
    Forms!EditErrorFileFrm!DirectFileBox.Caption = " "
    Forms!EditErrorFileFrm!OpenBtn.Enabled = False
    End If
    End If
    End Sub

  4. #4
    Join Date
    Sep 2003
    Location
    UK
    Posts
    122
    if you have the full path and file name then you should be able to do this

    Code:
    strCurrDir = Left$(StrFullName, InStr(StrFullName, FileName))
    you will need to get the full name and path in one string and the name in another the result is you effectivly subtract the filename from the fullname and path to give just the path.

    you may also find this link usefull: http://www.mvps.org/access/api/api0002.htm
    Matt the Hat says: "what!?"
    A child of five could understand this! Fetch me a child of five!
    SCARY HARD CHALLENGE: http://www.dbforums.com/showthread.php?threadid=988682

  5. #5
    Join Date
    Aug 2003
    Posts
    106

    thanks!

    Thanks for this!

    Access automatically finds a filename in the previous code because the Dir statement just supply's the filename.

    What i need to do is get the full path from just this filename. Is there any way i can get the full path from the file? For example if the file was open, could i get the path from it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •