Solved

cant find new file

Posted on 1998-07-26
2
133 Views
Last Modified: 2010-05-18
Hello I got his pice of code, trying to read a file, I get a path/access error.
Do you know what I am doing wrong.
The should be of anyname.job, and shall show up in the textfield. It is to read an autogenerated file, when it shows up.
It is written in the timer_time proc.


sti = "C:\Guestlog\"

Dir1.Path = sti
Dir1.Refresh
File1.Pattern = "*.*"
File1.Refresh

If File1.ListCount > 0 Then
f = FreeFile
Open sti & File1.filename For Input As f
Text1.Text = Input$(LOF(f), f)
Close

End If
0
Comment
Question by:CATT
2 Comments
 

Author Comment

by:CATT
ID: 1466773
Edited text of question
0
 
LVL 6

Accepted Solution

by:
alamo earned 80 total points
ID: 1466774
One big problem is that File1.filename gives you the selected filename, and File1.refresh clears the selection. Therefore file1.filename is blank and you are trying the equivalent of:

Open C:\Guestlog\" For Input As f

which won't work.

What you want to do is use the Dir function:

fname = Dir(sti & "*.*")
if fname <> "" then
    f = FreeFile
   Open sti & fname For Input As f
    Text1.Text = Input$(LOF(f), f)
    Close
End If

Hope this helps!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question