Solved

cant find new file

Posted on 1998-07-26
2
134 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

830 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