VBA Loop for different form parameters

McObraz

Registered User.
Local time
Today, 02:41
Joined
Nov 21, 2011
Messages
37
Hello,

I have a sample database (attached) where I have a form called frmVoteHeadsOne. The voteheads that I have are swimming (Swim) and transport (Trans), which both appear for data in a table. On the form, from the combo list, I would wish that if I select swimming, for example, only Mark Tyler's name is returned since he has paid 2000; if I select Transport from the same list, only John clement's name is returned.

My purpose for doing this is because in the actual database, I have 21 different voteheads which I would like to get different results from based on what the user selects from the combo list.

Possible?

Thanks for the help.

Maurice.
 
yes, in a continuous form, put the combo in the header.
in the combo AFTERUPDATE event, filter the data on the combo,
Code:
private sub combo_afterupdate()
   me.filter = "[field]='" & me.comboBox & "'"
  me.filteron = true
end sub
 
Ranman256,

Thank you for your quick response. Yes, the code you have provided me works if I were to filter one field (say swimming) and the result would only depend on the data in the Swim field. However, the code I need is one that would filter the data based on whatever the user selects from the list, keeping in mind that each of the items on the combo box list represents a different field in a table.

Again, thanks for your help.

Maurice.
 
that is not a normal database, as if you are referring to an excel spreadsheet.
 
For some reason, I thought I had attached the sample database, but I cannot see it in my previous posts. Sorry. Here it is.

Thanks.

Maurice
 

Attachments

here, check this out.
 

Attachments

Arnelgp,

Thanks for your response. Sorry I lost power in the office, so I could not respond. I have gone through the code and I am seeing that it returns only one name, regardless of the data that I choose from the listbox. I cannot figure out where the problem is.

Again, thanks for your help.

Maurice.
 
On the form, from the combo list, I would wish that if I select swimming, for example, only Mark Tyler's name is returned since he has paid 2000; if I select Transport from the same list, only John clement's name is returned.

this is what your requirement, so only those with amounts (amount > 0) on those fields are returned.
 
arnelgp,

Thanks for the clarification and sorry for the late response. Been out of the office since. Yes, it worked. Much appreciated.

Maurice.
 

Users who are viewing this thread

Back
Top Bottom