Checking which combo is choosen

haavar

Registered User.
Local time
Today, 15:40
Joined
Jun 26, 2006
Messages
48
I have to found out which combo box the user has choosen. I use 4 combos + two text fields.
The easy solution is that you have to choose only one combo at a time, but I the user should choose several at the same time before they click "Make report".

Heres the code: (I use global variables, defined in Module)
Code:
Private Sub Combo21_Change()
kombo1test = True
End Sub
Private Sub Combo23_Change()
kombo2test = True
End Sub

Private Sub Combo5_Change()
kombo3test = True
End Sub

Private Sub Combo7_Change()
kombo4test = True
End Sub

Private Sub Command14_Click()
On Error GoTo Err_Command14_Click
    Dim stDocName As String
    
'Start If test
'Åpner rapport basert på saksansvarlig OK
If (kombo1test = True) Then
DoCmd.OpenReport "Ansvarlig", acPreview, , where
where = "[Feil_problem.ansvarlig]= [Combo21]"
kombo1test = False

'Åpner rapport basert på system OK
ElseIf (kombo2test = True) Then
DoCmd.OpenReport "System", acPreview, , where
where = "[Feil_problem.system]= [Combo23]"
kombo2test = False

'Åpner rapport basert på fabrikk OK
ElseIf (kombo3test = True) Then
DoCmd.OpenReport "Fabrikk", acPreview, , where
where = "[Feil_problem.fabrikk]= [Combo5]"
kombo3test = False

'Åpner rapport basert på område OK
ElseIf (kombo4test = True) Then
DoCmd.OpenReport "Omraade", acPreview, , where
where = "[Feil_problem.omraade]= [Combo7]"
kombo4test = False

And I am testing a iftest with more statements, how to choose more than one?
Code:
ElseIf (kombo1test = True And kombo2test = True) Then
DoCmd.OpenReport "Saksansvarlig_system", acPreview, , where
where = "[Feil_problem.ansvarlig]= [Combo21] AND [Feil_problem.system]= [Combo23]"
kombo1test = False
kombo2test = False

I hope someone do have som tips on this:)
Thanks in advance
 
Specifically say what is your need. Do you want to ensure that only one combo box is selected before the user clicks the command button to make report? What is the job of your text boxes? Put clear questions here. If not you will not get replies.
 
....

"I have to found out which combo box the user has choosen" Via a variable or something. If you read the code, you see.
I think this is clear enough, but I can say more about it.

When combo is changed the variable sets to TRUE, if not, nothing happens.
The user have to choose the report material by the multi comboboxes or/and with from and to date. How can I ensure this? I try to use the global variable, but it works only with one combo at a time. How can I fix this?
When combobox 1 and 2 is changed, then run a report with where clause.

I hope this help guys.....sorry
 
Can someone help, please?

Can someone help, please?
 
Fixed

I found the solution. I had to use a if/else loop that set an integervalue on a Select case. More spesific for VBA
 
There is an alternative method using the LIKE comparator and the Wildcard *

So Like * & MyCombo will return the combo selection if there is one, or just the wildcard if there is not. This permits any combination of combos to be used.
 
thanks...

That was a new thing:) Nice with something new to learn, thats always
 

Users who are viewing this thread

Back
Top Bottom