Hi again
I had to tweak the code and set up a bit to make it workable with my needs. Also I created an additional query where the range of item numbers needed is extracted into a table, and a query with the needed SQL is based on this table. Here I have a row counter as a new numeric count which I use for “Do Until” code (Field: DataLinkId).
This all works just fine. The reports are saved, currently with the counter ID (Field: DataLinkID) so the file name reads;
1 databladMG.pdf
2 databladMG.pdf
3 databladMG.pdf
Etc.
My issue is that I stil need the files to be saved with the “Item-Number” field information instead of the “DataLinkId”. So I tried to change the it to contain “Item_Number” instead of “DataLinkId” in several different ways. But all I get is that the Last report is saved with the file name of the first “item_number”.
I need the filename to be following syntax: Item_number & strSufix
Since the filename set up can be just about anything, I can’t seem to locate why I can’t make it work with the “item_number” instead of the “DataLinkID” number…..
Hope you can put your finger on it……
Here’s the code, still only in trail mode
#
Dim strsql_rsl As String
strsql_rsl = "SELECT tblrowcounter_testA.Data_Lev_Number, tblrowcounter_testA.DataLinkId, tblrowcounter_testA.FieldRptNumb, tblrowcounter_testA.id, tblrowcounter_testA.Item_number, tblrowcounter_testA.DataID, tblrowcounter_testA.Datasets, tblrowcounter_testA.DataItems, tblrowcounter_testA.datatickedoff, tblrowcounter_testA.text1, tblrowcounter_testA.text2, tblrowcounter_testA.text3, tblrowcounter_testA.text4 from tblrowcounter_testA order by tblrowcounter_testA.DataLinkId"
Dim intDataLinkId As Integer
Dim strRptname As String
Dim strPrefix As String
Dim strSufix As String
Dim strURL As String
Dim strFrmName As String
strRptname = "RptData_testA"
strPrefix = "C:\A_Transfer\"
strSufix = " data sheet MG.pdf"
strFrmName = "Form1_testA"
Set rsrptnumb = curdb.OpenRecordset(strsql_rsl, dbOpenForwardOnly)
Do Until rsrptnumb.EOF
intDataLinkId = rsrptnumb!DatalinkID
prpSQL_ForRpt = fSQL_ForRpt(intDataLinkId)
DoCmd.OpenReport strRptname, acViewReport, , , , Me.Name
strURL = strPrefix & intDataLinkId & strSufix
'MsgBox " >>> " & strURL
DoCmd.OutputTo acOutputReport, strRptname, acFormatPDF, strURL
DoCmd.Close acReport, strRptname
rsrptnumb.MoveNext
Loop
#