?
Solved

cant find new file

Posted on 1998-07-26
2
Medium Priority
?
137 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

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

Accepted Solution

by:
alamo earned 320 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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

719 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