Can an unbound combo box to filter form entries down to a specific year? (1 Viewer)

gojets1721

Registered User.
Local time
Today, 12:32
Joined
Jun 11, 2019
Messages
429
I have a DB full of customer complaints ranging back several years and a form that looks at each complaint one by one. Is it possible to have an unbound combo box where the user can select a certain year and the form is filtered down to just complaints from that year.

I attached an example DB if helpful. If possible, in a perfect world, the combo box would default to the current year when opened. And then the user can change the year from there.
 

Attachments

  • Example.accdb
    576 KB · Views: 353

theDBguy

I’m here to help
Staff member
Local time
Today, 12:32
Joined
Oct 29, 2018
Messages
21,358
Hi. Probably not the best approach, but should give you an idea.
 

Attachments

  • Example.zip
    28.4 KB · Views: 357

gojets1721

Registered User.
Local time
Today, 12:32
Joined
Jun 11, 2019
Messages
429
Hi. Probably not the best approach, but should give you an idea.
This worked well! If I wanted to have a specific year as the default rather than the current year, any idea how? I tried changing the default value in the Combo Box to "2019" and that set it as default, but that didn't filter down to only 2019 complaints. I also tried the below code in the after update VBA but same result.

Code:
Private Sub Form_Load()
   DoCmd.Maximize
  
   Me.Combo20 = Me.Combo20.ItemData(1)
  
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:32
Joined
Oct 29, 2018
Messages
21,358
Me.Combo20 = Me.Combo20.ItemData(1)
That looks like you're trying to simulate selecting something from the Combobox. If so, try it this way:
Code:
Call Combo20_AfterUpdate()
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:32
Joined
Sep 21, 2011
Messages
14,046
@templeowls
I hear you have made a complaint about me for a link I posted for your query on this thread.?
I never mean to offend anyone deliberately, but I will put you on my ignore list now, so not to even remotely appear to do that again.

And something I said must have helped, as now you appear to be doing what I suggested in another thread? :unsure: :(
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 19:32
Joined
Sep 12, 2006
Messages
15,614
I would have a column in the query for datayear: year(transactiondate). (you might be able to call it year, but maybe not)
Then use the combo to filter for matches against this working column.
 

Users who are viewing this thread

Top Bottom