Using list Box to sort data in the report (1 Viewer)

Finance

Registered User.
Local time
Today, 12:00
Joined
Jul 11, 2018
Messages
59
Hi,

I have a database of patent costs in access 2016.
I have created a list box on the report and would like to sort fields on the report depending if the list box says yes/no.

Thanks for your help in advance.
 

Ranman256

Well-known member
Local time
Today, 15:00
Joined
Apr 9, 2015
Messages
4,339
List boxs don't work on reports.
You can use it on a form,then open the report with that sort.
 

Finance

Registered User.
Local time
Today, 12:00
Joined
Jul 11, 2018
Messages
59
Hi!

thanks for replying!

yes, no wonder i cant seem to sort it through the report.
Could you give me an example of how I can use it through a form?

Problem:
these are the details on my form.
Complexity 1:
I want my report to show that the office action record in the field: Nature of Expenses is ($3000*1=)$3000 because the complexity is 1.
can this be done?
 

Finance

Registered User.
Local time
Today, 12:00
Joined
Jul 11, 2018
Messages
59
Thanks !!!! This is exactly what I was looking for. :D
 

jdraw

Super Moderator
Staff member
Local time
Today, 15:00
Joined
Jan 23, 2006
Messages
15,379
Good stuff.
Happy to help.
 

Finance

Registered User.
Local time
Today, 12:00
Joined
Jul 11, 2018
Messages
59
Hi,

There is an error with the filtering on the database. I have put the code in using the combo box to filter out the years but there is an error in the filtering VBA code, I am attaching my database.
Please help.
 

Attachments

  • Database - Final Latest.zip
    236.4 KB · Views: 378

Finance

Registered User.
Local time
Today, 12:00
Joined
Jul 11, 2018
Messages
59
I did try the code yesterday and it worked like a dream but theres a problem coming up now and I cant figure out the reason. Thanks for helping in advance
 

JHB

Have been here a while
Local time
Today, 21:00
Joined
Jun 17, 2012
Messages
7,732
The problem is because you convert the criteria to a string value, use the below code.
Code:
Private Sub CommandAPplyFilter_Click()
    Dim strYears As String
    Dim strFilter As String
' Check that the report is open
    If SysCmd(acSysCmdGetObjectState, acReport, "Patent_Cost_Forecast") <> acObjStateOpen Then
        MsgBox "You must open the report first."
        Exit Sub
    End If
' Build criteria string for Office field
    If Not IsNull(Me.Combo8.Value) Then
      strYears = "=" & Me.Combo8.Value & ""
    End If
' Combine criteria strings into a WHERE clause for the filter
    strFilter = "[Years] " & strYears
' Apply the filter and switch it on
    With Reports![Patent_Cost_Forecast]
        .Filter = strFilter
        .FilterOn = True
    End With

End Sub
 

Finance

Registered User.
Local time
Today, 12:00
Joined
Jul 11, 2018
Messages
59
I have tried this code but the criteria is for a string data type whereas my data type for years is long integer.
How can i Modify this code for a long integer data type ?
Thanks!
 

JHB

Have been here a while
Local time
Today, 21:00
Joined
Jun 17, 2012
Messages
7,732
I have tried this code but the criteria is for a string data type whereas my data type for years is long integer.
How can i Modify this code for a long integer data type ?
Thanks!
It is for integer values.
 

Attachments

  • Database - Final Latest.accdb
    876 KB · Views: 382

Users who are viewing this thread

Top Bottom