473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

MultiSelect For Parameters

Hello Everyone,

I have an access application that has a listbox on a form. The list box is set to multiselect. I want to be able to use the selected items in a parameterized query that is predefined in access. The reason for this is that I need to run a transfertext macro that uses the query as a table. I have put the selected items from the listbox into a control on the form. The where clause looks like 'BABY FOOD' Or 'AUTOMOTIVE' if you select those from the list. Then I take what is in the control [Form]![frmWhatever]![txtBox] which = 'Baby Food' Or 'Automotive' and use it as a parameter in a predefined query. So the where clause for the query looks like [Form]![frmWhatever]![txtBox] and the parameter I have set is the same. When I click the button the where clause is built and put into the textbox and then the string in the textbox is used as parameters for the query. This doesn't work. The transfertext function gives me an empty CSV file unless I only select ONE item at a time... Any Reason for this?
Jul 17 '07 #1
3 1542
JKing
1,206 Expert 1GB
Could you post the code for the query and the code you are using to build your where criteria? It sounds like you are building the where criteria improperly. If the string isnt right the query will return nothing and produce the empty file.
Jul 17 '07 #2
MikeTheBike
639 Expert 512MB
Hi
Hello Everyone,

I have an access application that has a listbox on a form. The list box is set to multiselect. I want to be able to use the selected items in a parameterized query that is predefined in access. The reason for this is that I need to run a transfertext macro that uses the query as a table. I have put the selected items from the listbox into a control on the form. The where clause looks like 'BABY FOOD' Or 'AUTOMOTIVE' if you select those from the list. Then I take what is in the control [Form]![frmWhatever]![txtBox] which = 'Baby Food' Or 'Automotive' and use it as a parameter in a predefined query. So the where clause for the query looks like [Form]![frmWhatever]![txtBox] and the parameter I have set is the same. When I click the button the where clause is built and put into the textbox and then the string in the textbox is used as parameters for the query. This doesn't work. The transfertext function gives me an empty CSV file unless I only select ONE item at a time... Any Reason for this?
Unfortunatly you cannot do this (to my knowledge - not sayng too much) because the query will look like this

"WHERE SomeFieldName = 'BABY FOOD' OR 'AUTOMOTIVE'
when it should look like this
"WHERE SomeFieldName = 'BABY FOOD' OR SomeFieldName = 'AUTOMOTIVE'

In short no record contains the value of "'BABY FOOD' Or 'AUTOMOTIVE' "
hence no records.

The only way I have found round this, when a stored query is absolutly necessary, is to build a query string in code and create a query definition on the fly, and that can be problematic in a multiuser envionment with a common front end.

But that is nt what you want hear!

My only suggestion, if possible/practical, would be to loop through the selected items in the list and perform you action(s) on each item, ie. single Where Field = '...'

Any help?


MTB
Jul 17 '07 #3
[quote=MikeTheBike]Hi


Unfortunatly you cannot do this (to my knowledge - not sayng too much) because the query will look like this

"WHERE SomeFieldName = 'BABY FOOD' OR 'AUTOMOTIVE'
when it should look like this
"WHERE SomeFieldName = 'BABY FOOD' OR SomeFieldName = 'AUTOMOTIVE'

In short no record contains the value of "'BABY FOOD' Or 'AUTOMOTIVE' "
hence no records.

The only way I have found round this, when a stored query is absolutly necessary, is to build a query string in code and create a query definition on the fly, and that can be problematic in a multiuser envionment with a common front end.

But that is nt what you want hear!

My only suggestion, if possible/practical, would be to loop through the selected items in the list and perform you action(s) on each item, ie. single Where Field = '...'

Any help?


Thanks fro the help. I figured out a way to do what I needed.
Jul 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Cassie Pennington | last post by:
I am trying to write various items from a multiselect list box to an SQL statement to update a report, without success. SQL only appears to accept hard-coded data or control values from a form, not...
1
by: tod4 | last post by:
Hi, My problem: I have query with value klient and product. On my form Im using multiselect box as filter of klient value. Now I would like to use second multiselect on this form for product...
6
by: ¿ Mahesh Kumar | last post by:
Hi groups, Control name : ListboxID (lstCertification), selection mode=mutliselect. On Pageload i'm assinging string lstSplit="1/3/6/8" of the previously selected listindex id's. Now on the...
0
by: Robert | last post by:
Hi, I have a program with a ListView (with Multiselect) and am using the SelectedIndexChanged handler. However, when the index is changed, a rather long set of events occurs which takes quite...
0
by: - HAL9000 | last post by:
Was/Is there a resolution to this bug of using ListView check boxes and MultiSelect together? I have the same difficulty as the author. ...
3
by: kaosyeti via AccessMonster.com | last post by:
hey... i have an unbound multiselect listbox on a form that i want to use to populate text boxes on that form. so if a user selects the 3rd item in a list of 20, how can i have that item show up...
5
by: martin DH | last post by:
Hello, The details are below, but I have a simple form (Form1) with two objects and a "search" command button. When the two objects are cascading combo boxes (the form creates the parameters for a...
2
by: jdom | last post by:
i am trying to pass the value "comapre" of 2,3, or 4 checkbox to next page but i am getting errors. Application uses a value of the wrong type for the current operation. LINE ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.