Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Sub c1_Click()
Dim myDb1 As DAO.Database, myRst1 As DAO.Recordset, myFile As String, myCurName As String
DoCmd.Close acReport, "Sales_Report"
Set myDb1 = CurrentDb
Set myRst1 = myDb1.OpenRecordset("SELECT DISTINCT tblcust.cName FROM tblCust;", dbOpenDynaset)
myRst1.MoveFirst
Do While Not myRst1.EOF
myCurName = Replace(myRst1.Fields(0), ",", "")
myCurName = Replace(myCurName, "'", "")
myCurName = Replace(myCurName, ".", "")
myFile = myCurName & "_" & Year(Date) _
& Format(Month(Date), "mm") & Format(Day(Date), "dd")
DoCmd.Rename "Sales_Report_ " & myFile, acReport, "Sales_Report"
DoCmd.OpenReport "Sales_Report_ " & myFile, 0, , "[cName] = " & "'" & myCurName & "'", acHidden
DoCmd.Close acReport, "Sales_Report_ " & myFile, acSaveYes
DoCmd.Rename "Sales_Report", acReport, "Sales_Report_ " & myFile
DoCmd.Close acReport, "Sales_Report", acSaveYes
myRst1.MoveNext
Loop
End Sub