Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2005, 04:49 PM
Registered User
 
Join Date: Dec 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello-

I figured it out and thought I would post the code to avoid future headaches for someone else.

- First I created 2 global variables to house my loc1 and loc2 fields
- Then I created a select all query for the data I needed to export...only I needed to use the getLoc1() function as a parameter for the Loc1 criteria and the getLoc2() function as a parameter for the loc2 criteria
- Lastly a do loop on the recordset and I'm also able to control where the file outputs to and the name.

The code:

Global gStrLoc1 As String
Global gStrLoc2 As String
Public Function GetLoc1() As String
GetLoc1 = gStrLoc1
End Function
Public Function GetLoc2() As String
GetLoc2 = gStrLoc2
End Function
Public Function ExpHourlyCheck()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
With rst
    .ActiveConnection = CurrentProject.Connection
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    .Open "Select * FROM ***insert your table name here****"

  Do Until .EOF
    gStrLoc1 = !CNL1LC (***my location1 variable***)
    gStrLoc2 = !CNL2LC (***my location2 variable***)
    DoCmd.TransferText acExportDelim, "PayrollExport Specs", "qryHourlyCheckExport", "\\MFFS05\MIS\Financials\Payroll " & !CNL1LC & !CNL2LC & Format(Now(), "mmddyyhhnnss") & " .csv", False
    .MoveNext
  Loop
  .Close
End With
Set rst = Nothing

End Function






Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop through 17 tables in RecordSet object didimichael C# 1 July 18th, 2008 06:53 AM
recordset not showing up on page loop pablohoney Classic ASP Databases 1 December 14th, 2005 06:43 PM
Filter recordset in loop Freddyfred Access 1 February 15th, 2005 09:09 AM
Kinda complicated loop through DB Recordset... plasma800 Classic ASP Basics 2 March 4th, 2004 06:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.