I have a button that performs some options in my database however, i want to beable to cycle through the records till the last and then stop.
Im not sure what functions i can use to do this, ive tried searching for it with no luck, thanks in advance.
Im not sure what functions i can use to do this, ive tried searching for it with no luck, thanks in advance.
Code:
Private Sub cmdAutomate_Click()
Dim objAccess
Dim strPathToMDB
Dim strTableName
Dim strFilePath
Dim AmtRecords
Dim CurrentRecord
Const acImportDelim = 0
Const acFormatHTML = "HTML (*.html)"
Const acOutputTable = 3
AmtRecords = RecordCount
CurrentRecord = 1
Me.lblRecord = AmtRecords
Me.lblCurrent = CurrentRecord
Set objAccess = CreateObject("Access.Application.10")
Do While CurrentRecord <= AmtRecords
strPathToMDB = ContestPath & ContestDBName
strFilePath = ContestPath & ContestName & ".htm"
' Open the desired database
objAccess.OpenCurrentDatabase (strPathToMDB)
' Use the TransferText command to import the file (with Column Heads)
' objAccess.DoCmd.OutputTo acOutputTable, strTableName, acFormatHTML, strFilePath, True
strTableName = "qmtSales"
objAccess.DoCmd.OpenQuery strTableName, acNormal, acEdit
strTableName = "qmtInside"
objAccess.DoCmd.OpenQuery strTableName, acNormal, acEdit
strTableName = "rptInside"
objAccess.DoCmd.OutputTo acOutputTable, strTableName, acFormatHTML, strFilePath, False
' Clean up
objAccess.CloseCurrentDatabase
objAccess.Quit
CurrentRecord = CurrentRecord + 1
DoCmd.GoToRecord , , acNext
Call MsgBox("Operation Completed", vbInformation Or vbSystemModal Or vbDefaultButton1, "Done")
Loop
Set objAccess = Nothing
End Sub
Last edited: