Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

open on load

Posted on 2007-03-24
5
Medium Priority
?
262 Views
Last Modified: 2010-04-30
hello,
I would like to have this load once the app is executed in Form_Load
and not in mnuOpen_Click how can i do it ? the file im trying to open is
App.Path & "accounts1.txt"


Private Sub mnuOpen_Click()
OPEN_NEW:
  Dim tmpPath As String
  tmpPath = ShowFileDialog(Me.hWnd, stOPEN, "Text Files (*.acc)|*.acc", "Select Tab Delimited File", App.Path)
  If Not tmpPath = "" Then
  LoadFile tmpPath, lvwMain
  End If
frmMain.Caption = "Accounts Currently Added [" & lvwMain.ListItems.Count & "]"
End Sub

Public Sub LoadFile(mPath As String, LVW As ListView)
  'clear any previous items in the listView
  LVW.ListItems.Clear
  Set FSO = New FileSystemObject
  'open the file for reading
  Set TS = FSO.OpenTextFile(mPath, ForReading, False)
  'cycle through the rest of the file to add the items
  While Not TS.AtEndOfStream
    'split the line into a string array
    tabLine = Split(TS.ReadLine, ":")
    If UBound(tabLine) = 4 Then
        Set lItem = LVW.ListItems.Add(, , tabLine(0))
        For J = 1 To UBound(tabLine)
            lItem.ListSubItems.Add , , tabLine(J)
        Next J
    End If
  Wend
  'close and clean up
  TS.Close
  Set TS = Nothing
  Set FSO = Nothing
End Sub
0
Comment
Question by:Sabrin
[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
  • 3
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18784989
AFAIK, App.Path does not contain the trailing \
this should work:
App.Path & "\accounts1.txt"
0
 

Author Comment

by:Sabrin
ID: 18784996
this is what I have but is not working

Private Sub Form_Load()
LoadFile App.Path & "\accounts1.txt", lvwMain
End Sub

when I execute the file it makes this line yellow

  Set TS = FSO.OpenTextFile(mPath, ForReading, False)
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18785015
and what error does it show (err.description)?
0
 

Author Comment

by:Sabrin
ID: 18785023
runtime error 53
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 18785041
that error means: file not found.
please ensure the file is really there (ie the app.path)!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 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…
Suggested Courses

670 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