I am attempting to export data from my database and create separate data files for each record.
I have created a form, and I am attempting to export all the records in the filter applied on that form. (This would depend on the dataset required at the time).
I have attempted to do this by creating a “Do Loop” as shown below.
Private Sub Command101_Click()
On Error GoTo Err_Command101_Click
Dim stDocName As String
Dim stDocName2 As String
stDocName = "HLA Server Questionnaire"
Do While Not acLast
DoCmd.GoToRecord , , acNext
stDocName2 = "HLA Server Questionnaire " & [Server_Name] & " - " & Date$ & ".xls"
DoCmd.OutputTo acReport, stDocName, acFormatXLS, stDocName2, True
Loop
Exit_Command101_Click:
Exit Sub
Err_Command101_Click:
MsgBox Err.Description
Resume Exit_Command101_Click
Whilst the code above does work, I know the loop is not really working, does anyone have any suggestions as to how to get my loop working correctly. – Thanks
I have created a form, and I am attempting to export all the records in the filter applied on that form. (This would depend on the dataset required at the time).
I have attempted to do this by creating a “Do Loop” as shown below.
Private Sub Command101_Click()
On Error GoTo Err_Command101_Click
Dim stDocName As String
Dim stDocName2 As String
stDocName = "HLA Server Questionnaire"
Do While Not acLast
DoCmd.GoToRecord , , acNext
stDocName2 = "HLA Server Questionnaire " & [Server_Name] & " - " & Date$ & ".xls"
DoCmd.OutputTo acReport, stDocName, acFormatXLS, stDocName2, True
Loop
Exit_Command101_Click:
Exit Sub
Err_Command101_Click:
MsgBox Err.Description
Resume Exit_Command101_Click
Whilst the code above does work, I know the loop is not really working, does anyone have any suggestions as to how to get my loop working correctly. – Thanks