boardgamer
Programmer
How is the best way to create an HTML file for each record in the database, and save it to a unique name (which is also stored in the database)
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 cmdMyFancyButton_Click()
[green]'Set up your variables[/green]
Dim db as DAO.Database
Dim rs as DAO.Recordset
Dim strSQL As String
Dim strFilePath As String
Dim strHTML1 As String
Dim strHTML2 As String
Set db = CurrentDb
Set db = db.OpenRecordset("tblMyFancyTable")
[green]'I'd probably first create the file name/location, and THEN create the files.
'Easiest way would be to just add a new column called FileName, manually,
'then procede to fill it with an Access query or some SQL code like following:[/green]
strFilePath = "C:\MyFancyFiles\"
strSQL = "UPDATE tblMyFancyTable " & Chr(13) & _
"SET FileName = strFilePath & RecordID & ".html"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
[green]'Then loop through the table, creating your files[/green]
Do While Not rs.EOF
[green]'Use the 2 strHTML variables (strHTML1 and strHTML2) to store the values other than your RecordID
'which you can slap between the 2, if that's the only difference.
'Then create the HTML file or text file, by specifying where it'll be saved
'and specifying the contents with your combined string of HTML..
'Of course, if you're just looking to create Access Pages to be reports of the records,
'you'll just need to create new Access Pages.
'And for that, you could probably create a template, and then create the new pages based off the template - just guessing[/green]
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub