Solved

cant find new file

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month11 days, left to enroll

628 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