473,394 Members | 1,759 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.

Refine a Stored Query for a ListBox based on a selection in a Combo Box

Hi,

Just joined and also a fairly new geriatric programmer to the land of MS ACCESS VBA :(

I have a table called 'transactions' and a query called qryTransactions. This query selects all records based on whether or not a flag called 'Sold' is set to 'No'. Working fine.

I have a list box (Multi Columns) which has a RowSource set to qryTransactions.

So far so good, when form loads, I get all 'Not Sold' records in the List Box.

There is a ComboBox fed from a table of customers - basically the CustomerName. When I select a name, I want to limit the qryTransactions just to the customer name selected from the combo box.

QUESTION: Is there a simple way to make use of a clause like 'WHERE Customer_Name = cboBox.value' so that the RowSource of the ListBox reflects this WHERE clause.

P.S. seen loads of complex VBA contortions around this issue, but for this geriatric, surely there must be a simple solution :(

Thanks for having a read - any pointers appreciated

Oliver
Feb 1 '19 #1

✓ answered by LenseOnLife

OK, I've sorted it out

Expand|Select|Wrap|Line Numbers
  1. Dim strSql As String
  2. strSQL = "Select SalesOrderId, TransactionDate, .... 
  3. FROM tblSalesOrders 
  4. WHERE  Customer_Name = '" & lstCustomers & "'"
  5. lstTransactions.RowSource = strSQL
  6. lstTransactions.Requery
And that's it :)

Oliver

1 1151
OK, I've sorted it out

Expand|Select|Wrap|Line Numbers
  1. Dim strSql As String
  2. strSQL = "Select SalesOrderId, TransactionDate, .... 
  3. FROM tblSalesOrders 
  4. WHERE  Customer_Name = '" & lstCustomers & "'"
  5. lstTransactions.RowSource = strSQL
  6. lstTransactions.Requery
And that's it :)

Oliver
Feb 1 '19 #2

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

Similar topics

1
by: David | last post by:
Hi everyone. I have read every page that Google returns on this topic, but can't find anything that resolves my problem. Basically, I have an Access Database that does a number of different...
2
by: neptune | last post by:
I have a query where each customer has an or . Sometimes both fields for a customer are populated, but if is null, then will be populated and vice versa. I have a form, , where I select a...
5
by: Dave H | last post by:
I have an asp:listbox, allowing multiple selections, is there a quick check to see if there's more than one selected, or do I need to go through the whole list? Thanks, Dave
1
by: daleshei | last post by:
I have a combo box with list all the queries I have on my database: Form is called: frm_qry_slct Combo box (Unbound): Combo23 RowSourceType: Table/Query RowSoource:SELECT FROM MSysObjects...
20
by: Daniel Yantis | last post by:
Combo Box 1 Displays a query/list with 2 columns: SELECT Classes.CLASS_DESC, Judges.Judge, * FROM Classes; Combo Box 2 Displays a query/list: SELECT Judges.Judge FROM Judges; I want...
2
by: Phil Dell | last post by:
Hi all, Extremely new to Access and VBA, I have been working my way through several books and sites, and I'm finally breaking down and crying for help. I am developing a...
4
by: Stoic | last post by:
Hi, I have a database with tables and fields. I have created a form that with three to four combo boxes and inserted a control button. I would like a write a code to query my data based on the...
8
by: Royunderwood | last post by:
I have a form with a listbox that I manually set the rowsource to in VBA. I have 2 filter buttons that changes the rowsource and requery the list box. This works great for a filter.. If a users...
2
by: pwag | last post by:
Good Afternoon, I'm trying to auto-select items in a multi-select listbox based on a column's criteria in a VBA Sub. Here is my code thusfar that fails. All values are text data type. Any...
0
by: mahmoudwahbeh | last post by:
Dears I am trying to do a small program on VB 6.0 to find the records in database and print it in text box based on combo box selection but i failed to find a code which allow me to do this. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.