Hello Everyone! I'm new to the site and thought i would sign up to try and get some advice. Firstly i apologize if i'm being dense in any way as i have not had to do any VB for some time now and i'm REALLY struggling to get back into it :banghead:
My problem is as follows, i have created a report that calculates the total volume of FSC Materials. The user picks two dates from Calender controls that the report will range from. However the needs have now changed and i am required to make the report filter further based on user input, the problem i'm facing is that i cannot figure out a way to pass values from different variables to the report separate from another here is the code i would usually use to pass data to a query/report: (again i apologize if this looks dreadful)
However i am now trying to do this, but it gives me an error as it is trying to pass the values to one field:
I have done the rounds on the internet but couldn't find anything that exactly matched what i'm trying to do. I have been reading about OpenArgs but am struggling to get to grips with them!
Any advice or help would be greatly appreciated.
Thanks
Alex
EDIT: I have now updated to try and use OpenArgs using this method:
It is performing incorrectly within the case select and passing the wrong criteria, as it will only display results that meet the default values' criteria. However the date criteria is not be passed either. Does anybody have any idea why?
Thanks
My problem is as follows, i have created a report that calculates the total volume of FSC Materials. The user picks two dates from Calender controls that the report will range from. However the needs have now changed and i am required to make the report filter further based on user input, the problem i'm facing is that i cannot figure out a way to pass values from different variables to the report separate from another here is the code i would usually use to pass data to a query/report: (again i apologize if this looks dreadful)
Code:
Private Sub MonthlyFSC_Click()
Msg = MsgBox("Select the Start and Finish Dates you wish to Query.", , "Start / Finish")
Start = adhDoCalendar()
Finish = adhDoCalendar()
sql1 = "[ORDER DATE]<#" & Format(Finish, "MM/DD/YY") & "#"
sql2 = "[ORDER DATE]>#" & Format(Start, "MM/DD/YY") & "#"
sql = "((" & sql1 & ") And (" & sql2 & "))"
Dim stDocName As String
stDocName = "rptMonthlyFSCVolumeReport"
DoCmd.OpenReport stDocName, acPreview, , sql
However i am now trying to do this, but it gives me an error as it is trying to pass the values to one field:
Code:
Msg = MsgBox("Select the Start and Finish Dates you wish to Query.", , "Start / Finish")
Start = adhDoCalendar()
Finish = adhDoCalendar()
sql1 = "[ORDER DATE]<#" & Format(Finish, "MM/DD/YY") & "#"
sql2 = "[ORDER DATE]>#" & Format(Start, "MM/DD/YY") & "#"
sql = "((" & sql1 & ") And (" & sql2 & "))"
Dim stDocName As String
stDocName = "rptMonthlyFSCVolumeReport"
Filter = InputBox("Please accept 100 for FSC 100% Items or Enter 'Mix' for FSC Mix Items", "Input FSC Volume Report", "100")
Select Case Filter
Case "100"
sql3 = "[DESCRIPTION] Like *FSC* And Like *100*"
DoCmd.OpenReport stDocName, acPreview, , sql & sql3
Case "Mix"
sql3 = "[DESCRIPTION] Like *FSC* And Not Like *100*"
DoCmd.OpenReport stDocName, acPreview, , sql & sql3
End Select
I have done the rounds on the internet but couldn't find anything that exactly matched what i'm trying to do. I have been reading about OpenArgs but am struggling to get to grips with them!
Any advice or help would be greatly appreciated.
Thanks
Alex
EDIT: I have now updated to try and use OpenArgs using this method:
Code:
Msg = MsgBox("Select the Start and Finish Dates you wish to Query.", , "Start / Finish")
Start = adhDoCalendar()
Finish = adhDoCalendar()
sql1 = "[ORDER DATE]<#" & Format(Finish, "MM/DD/YY") & "#"
sql2 = "[ORDER DATE]>#" & Format(Start, "MM/DD/YY") & "#"
sql = "((" & sql1 & ") And (" & sql2 & "))"
Dim stDocName As String
stDocName = "rptMonthlyFSCVolumeReport"
Filter = InputBox("Please accept 100 for FSC 100% Items or Enter 'Mix' for FSC Mix Items", "Input FSC Volume Report", "100")
Select Case Filter
Case "100"
sql3 = "[DESCRIPTION] Like *FSC* And Like *100*"
DoCmd.OpenReport stDocName, acPreview, , , , sql & sql3
Case "Mix"
sql3 = "[DESCRIPTION] Like *FSC* And Not Like *100*"
DoCmd.OpenReport stDocName, acPreview, , , , sql & sql3
End Select
It is performing incorrectly within the case select and passing the wrong criteria, as it will only display results that meet the default values' criteria. However the date criteria is not be passed either. Does anybody have any idea why?
Thanks
Last edited: