I have PDF documents attached to records. Well, the hyperlinks to their location on the server is actually in the records.
I have a query that gets DISTINCT records for a particular store from user input in a form. The output looks like this:
\\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\ACETONE.pdf
\\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\ACNE EXFOLIATING PADS.pdf
\\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Almond Oil.pdf
\\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Bain De Terre Infinite Hold Spray.pdf
\\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Batiste Dry Shampoo.pdf
\\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Canola Oil.pdf
\\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Coconut Oil.pdf
\\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Coppertone Sunscreen Sprays.pdf
That's fine for the first report.
For a second report, I need to trim the first 58 characters from the hyperlink. I figured I'd use
Mid([qryMSDSPrint.MSDS] As String, 59 As Number) As String
to do that. Is that correct?
I want my final report to look like this:
Store # Store Name
MATERIAL SAFETY DATA SHEETS
TABLE OF CONTENTS
A
ACETONE.pdf
ACNE EXFOLIATING PADS.pdf
Almond Oil.pdf
next page
Store # Store Name
MATERIAL SAFETY DATA SHEETS
TABLE OF CONTENTS
B
Bain De Terre Infinite Hold Spray.pdf
Batiste Dry Shampoo.pdf
Next page
Store # Store Name
MATERIAL SAFETY DATA SHEETS
TABLE OF CONTENTS
C
Canola Oil.pdf
Coconut Oil.pdf
Coppertone Sunscreen Sprays.pdf
I already have the page header set up for everything except the letter of the alphabet for that page.
I imagine I would use the LEFT function to get the letter of the alphabet for each page.
My issue is, I am really, really green at reports. When it comes to limiting a report using VBA, functions, etc. I don't even know where to begin.
The end result of all of this will be that someone will manually print all of the PDFs. The procedure I'm working on now will print out a cover page for each letter of the alphabet, kind of like using a TOC but not really. It needs to be alphabetized by the name of each document.
If it helps, here's my code for the button so far:
Code:'------------------------------------------------------------' btnMSDSSheetsPrint_Click ' '------------------------------------------------------------ Private Sub btnMSDSSheetsPrint_Click() On Error GoTo btnMSDSSheetsPrint_Click_Err If IsNull(Me.cboCompany) Then MsgBox ("Choose a Company!") Me.cboCompany.SetFocus Exit Sub End If If IsNull(Me.cboStore) Then MsgBox ("Choose a Store!") Me.cboStore.SetFocus Exit Sub End If DoCmd.OpenQuery "qryMSDSPrint" DoCmd.OpenReport ("rptMSDSTblOfCntnts") ExitS: DoCmd.Echo True Exit Sub btnMSDSSheetsPrint_Click_Exit: Exit Sub btnMSDSSheetsPrint_Click_Err: If Err.Number = 2501 Then MsgBox ("No records exist for this store/company!") Else MsgBox Error$ End If Resume btnMSDSSheetsPrint_Click_Exit End Sub
The line I put in red above is the line that will run the report that I'm trying to format right now.
Thanks, everyone, for your help. I truly appreciate it.
Marcie