Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2006

Tip: Looking for answers? Try searching our database.

Stepping through code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 20 Sep 2006 09:22 GMT
Hi,

I have written some code that I want to step through.  From my limited
knowledge of Access there is no other way of running this code without using
a button (on click) to kick it off.

The reason I want to do this is to get the following code to run.

Private Sub LoadFile(sDir_and_Path As String)
On Error GoTo Macro1_Err
   
   DoCmd.TransferText acImportDelim, "PO_Spec", "Tbl_PO_Listing",
sDir_and_Path

Macro1_Exit:
   Exit Sub
Macro1_Err:
   MsgBox sFile & ":  " & Error$
   Resume Macro1_Exit
End Sub

Public Sub I_LoadFiles(sDir_and_Path As String)
   Dim dbsStatus As Database
   Dim rstFiles  As Recordset
   Dim StrReq    As String
   Dim dTDate    As Date
   
   DoCmd.SetWarnings False
   Set dbsStatus = CurrentDb
   StrReq = "SELECT * FROM Tbl_Filenames"
   Set rstFiles = dbsStatus.OpenRecordset(StrReq)

   With rstFiles
       Do While Not .EOF
           If !File.Import = True Then
               Call LoadFile(sDir_and_Path)
           End If
           .MoveNext
       Loop
       .Close
   End With
   dbsStatus.Close
   
   DoCmd.SetWarnings True
End Sub

I didn't write the code but I'm pretty sure I can degug itonce it gets going
but I can't get the module to start.  I've tried to create a button with an
on-click procedure and then for that procedure to call LoadFiles but I get
the following error.

The expression on-click you entered as the event propert setting produced
the following error: Procedure declaration does not match description of
event or procedure having the same name.

Is there an easy way to simply point the button to the LoadFiles code?  

I'm expecting the code will look at a list of files in a table
(Tbl_Filenames) and import the contents into another table 'Tbl_PO_Listing'.

Signature

Andrew

Brendan Reynolds - 20 Sep 2006 10:06 GMT
You can run a public procedure defined in a standard module by typing its
name followed by any required arguments in the Immediate Window. Press
Ctrl+G to open the Immediate Window and enter something like ...

I_LoadFiles "C:\SomeFolder"

Note that I'm only guessing here as to what sort of value the argument is
supposed to contain.

Looking at the code, this line looks dodgy ...

           If !File.Import = True Then

The "." character is not a legal character in a field name.

Signature

Brendan Reynolds
Access MVP

> Hi,
>
[quoted text clipped - 59 lines]
> (Tbl_Filenames) and import the contents into another table
> 'Tbl_PO_Listing'.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.