|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Multiple parameters from 1 combo value
Hi all.
I've got a combo box set up with values X,Y,Z. When the user clicks on X, a hidden textbox gets populated with values "1 Or 2 Or 3" and I reference that textbox in the query criteria field. The problem is I haven't had any success with it. If the textbox=only one value, the query works fine. If I try to use more than one value, nothing happens. I've tried every variation I can think of "[1] Or [2] Or [3]" What am I missing? Any advice will be most appreciated. Thanks! |
|
#2
|
|||
|
|||
|
Hi Knia,
Could you please be a bit more specific to ur problem.Your problem is not clear..Are you having more than one combo boxes or using a single combo with multiple selection..in any case you can use that vaue only in ur query criteria..i am not understanding y r u using hidden text box for that... |
|
#3
|
|||
|
|||
|
Hi Sanguine. Sorry if I was unclear. I'll try to be more specific.
I have a switchboard form that's set up with 1 combo box. The values in the combo box represent cost centers. I have the form password protected so that when a manager selects their cost center and gives the correct password, they are taken to another form that acts as a second switchboard where they can pull various reports for their team. That's where the hidden textbox comes in. I populate the textbox with the value from the combo box so the main switchboard form can be closed. Then I reference the textbox value in the queries' cost center criteria field so that they only see information for their own cost centers. (ex/ If the cost center is 08X, the textbox value = "08X". The query references the textbox in the criteria field.) And this works GREAT if there's only one cost center. My issue is I don't know how to code it so that the textbox can equal more than one cost center at the same time. For instance, under a certain cost center (10X) there are 3 other cost centers that report to it (01X,02X,05X). How can I code it so that the textbox value gets referenced in the query criteria field as "01X" Or "02X" Or "5X"? Thanks for your help! |
|
#4
|
|||
|
|||
|
Hi,
I would try to split the string in the text box into individual variables and then compile them into one string, formatted as a query. The string should be easily split by the ',' and you could count the number of comma's to tell you how many variables are required for the query. eg 2 commas means there are three variables so the query would be Select * FROM tablename where field = " & str1 & " or " & str2 " or " str3. I think you can define variables on the fly in VB, otherwise define the max amount you know you will need. It will be important to have some way of counting how many variables are required so you know what to include in the query statement if you are not confident of checking for a null string before appending it to the statement in a loop. See how you go. I cant be of much help in writing code for you as I am new to VB syntax. |
|
#5
|
|||
|
|||
|
Thanks Useless.
I'll give it a shot. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Multiple parameters from 1 combo value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|