473,881 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to filter combo box but only new records

24 New Member
I have a form with a subform in my database that I use to manage deliveries. A combo box on the subform displays items of inventory and thier current status. The code behind the combo box is...
Expand|Select|Wrap|Line Numbers
  1. SELECT Inventory.InventoryID, Inventory.ProductCode, Inventory.SerialNumber, [Inventory Status].InventoryStatus
  2. FROM [Inventory Status] INNER JOIN Inventory ON [Inventory Status].InventoryStatusID = Inventory.InventoryStatusID;
A second combo box on the same subform allows me to change the inventory status; eg: from 'Available' (1) to 'Sold' (5).

The subform allows me to display multiple items for delivery. When I select a new item for delivery I do not want to see any of the items that have a status of Sold. I have tried setting the criteria in the combo box query to InventoryStatus ID < 5 but this clears the previous entries where I set the status to Sold.
I think I need to put an 'IF New Record' statement into the combo box query. Something like...
'If new record select from Inventory where Inventory status less than 5, Else select unfiltered'.

Can someone help please
Jun 23 '09 #1
18 4158
ADezii
8,834 Recognized Expert Expert
@Richard Penfold
I am a little hazy on your request, but to me it appears that you wish to dynamically change the RowSource of the 1st Combo Box based on whether or not it is a New Record. The general idea would be something similar to:
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3. If Me.NewRecord Then
  4.   strSQL = "SELECT Inventory.InventoryID, Inventory.ProductCode, Inventory.SerialNumber, " & _
  5.            "[Inventory Status].InventoryStatus FROM [Inventory Status] INNER JOIN " & _
  6.            "Inventory ON [Inventory Status].InventoryStatusID = Inventory.InventoryStatusID;"
  7. Else
  8.   strSQL = "SELECT Inventory.InventoryID, Inventory.ProductCode, Inventory.SerialNumber, " & _
  9.            "[Inventory Status].InventoryStatus FROM [Inventory Status] INNER JOIN " & _
  10.            "Inventory ON [Inventory Status].InventoryStatusID = Inventory.InventoryStatusID " & _
  11.            "WHERE [Inventory Status].InventoryStatusID < 5;"
  12. End If
  13.  
  14. Me![cboFirstCombo].RowSource = strSQL
Jun 23 '09 #2
Richard Penfold
24 New Member
Hi ADezii,
You have the right idea but I don't think I gave you enough information in my first post.
Deliveries_Inve ntory is a bound control combo box
Expand|Select|Wrap|Line Numbers
  1. Record Source = Deliveries_Inventory
  2. Row Source = SELECT Inventory.InventoryID,
  3.                     Inventory.ProductCode,
  4.                     Inventory.SerialNumber,
  5.                     [Inventory Status].InventoryStatus
  6.              FROM [Inventory Status] INNER JOIN Inventory
  7.                ON [Inventory Status].InventoryStatusID=Inventory.InventoryStatusID;
When I select an item from inventory to deliver I need to filter out inventory that already has a status of 'Sold' , but still be able to see records on the same subform that were processed previously that now have a status of 'Sold'

I imagine I can do this if I can include If or Case statements as part of the row Source, similar to that shown below

If
New Record
Expand|Select|Wrap|Line Numbers
  1. SELECT Inventory.InventoryID,
  2.        Inventory.ProductCode,
  3.        Inventory.SerialNumber,
  4.        [Inventory Status].InventoryStatus
  5. FROM [Inventory Status] INNER JOIN Inventory
  6.   ON [Inventory Status].InventoryStatusID = Inventory.InventoryStatusID
  7. WHERE ((([Inventory Status].InventoryStatus)<>"Sold"));
Else
Expand|Select|Wrap|Line Numbers
  1. SELECT Inventory.InventoryID,
  2.        Inventory.ProductCode,
  3.        Inventory.SerialNumber,
  4.        [Inventory Status].InventoryStatus
  5. FROM [Inventory Status] INNER JOIN Inventory
  6.   ON [Inventory Status].InventoryStatusID = Inventory.InventoryStatusID;
End If

But I could be wrong...
Jun 24 '09 #3
ADezii
8,834 Recognized Expert Expert
@Richard Penfold
So, if I understand you correctly, after you select an Item from the Deliveries_Inve ntory Combo Box, and if this is a New Record, you wish to display all entries in Deliveries_Inve ntory that are not Sold. Again, if it is a New Record, you also wish to display Records in the Sub-Form that are Sold?
Jun 24 '09 #4
Richard Penfold
24 New Member
Hi ADezii,
That is correct mate. I think I have the query right but I do not know the syntax to turn the queries into an If-then-else statement that I can put into query builder.
Jun 24 '09 #5
ADezii
8,834 Recognized Expert Expert
@Richard Penfold
I do not know the syntax to turn the queries into an If-then-else statement that I can put into query builder.
Kindly explain what you mean.
Jun 24 '09 #6
Richard Penfold
24 New Member
Hi ADezii,
Lets start at the beginning...
I have a Transactions table that has a 1-to-many relationship with Transaction Details table. Transaction Details has a 1-to-many relationship with Deliveries table. I also have an Inventory Status table that has a 1-to-many relationship with an Inventory table. The Inventory table itself has a 1-to-many relationship with the Deliveries table. Referential integrity is enforced on all joins.

My form is a Main form/Subform. Main form bound to Transactions Table, Subform bound to Deliveries Table. On the subform I have a bound control Combo box The control source is bound to the Deliveries table. The Row source selects from Inventory and Inventory Status tables. I have formatted the combo box to display product code, serial number and status in the drop down list but only the product code after selecting from the list. Other fields on my form are auto completed resulting from my selection. For any one transaction there can be many inventory items delivered. Simplisticly the form looks like this:
___________
Main
Customer Order Number Other details
___________
SubForm
Inventory Item Serial Number Status Delivery Date
Inventory Item Serial Number Status Delivery Date
Inventory Item Serial Number Status Delivery Date
etc...

Now to the problem...
In Design Mode...When I open the properties of Deliveries_Inve ntory combo box and click the Row Source 'Build' button, it launches Query Builder. In Query Builder I have a query to select the fields I want from the Inventory and Inventory Status tables. When I return to Forms Mode the combo box lists all inventory items by product code, serial number and status. Using this form I select from inventory, items that my customer has requested. Using another control on the form I set the status of the item selected to Sold so that I do not try to sell the same item twice. Over time, many inventory items will be sold and I do not want to trawl through an endless list to find items that are 'Available'.

I can set a criteria on the combo box in Query Builder to filter out inventory items that have a status of sold but when I move from one transaction to another, items selected previously are now blank. I need items already entered not to be filtered out by the query but new entries filtered so that I do not see previously sold items listed.

I think I should be able to do this in Query Builder by editing the query in SQL View but I do not know how to code the 'If New - Then - Else' statements I need around the queries.
Jun 25 '09 #7
ADezii
8,834 Recognized Expert Expert
Hello Richard Penfold. At this point I am hopelessly lost and cannot comprehend exactly what the problem is without some visual cue. Is there any possibility of sending me the DB to my private E-Mail Address?
Jun 25 '09 #8
Richard Penfold
24 New Member
Hi ADezii,
It will take some time to get a copy of the database to you but I guess I overcomplicated the problem with my explanation. If we focus on the combo box alone I think you can help.

The dropdown list as viewed in the combo box design grid is attached to this post.

Column 1 is hidden so the combo box drop down list displays: Product, Serial Number and Status

After making a selection from the drop down list, the combo box is populated with that selection. Each time I make a selection, a new row is generated on my form.
The combo box in the new row is blank (a new record) until I make a selection from the drop down list.
An image of the form is also attached to this post.

Initially, the Inventory Status is set to "Available" . After making a selection I change this status using another control on my form, to "Sold"

If I set a criteria for the combo box: 'Inventory Status <> "Sold"', on reopening the form, the drop down list does not include items with the status "Sold" but the combo box is also blank in all previous rows.

How do I make the combo box not list items where the status is "Sold" but still populate previous rows with my selection, now having a status of "Sold"?
Attached Images
File Type: jpg Design Grid.jpg (18.3 KB, 585 views)
File Type: jpg Form.jpg (12.8 KB, 389 views)
Jun 27 '09 #9
ADezii
8,834 Recognized Expert Expert
Hello Richard. For some reason or another I am really stuck on this Thread, and I do apologize for my incompetence in this matter. The good news is that I requested a few of my comrades to have a look at it for you. If you still have the capability to E-Mail the DB to me in the meantime, I would be happy to have a look at it. Just let me know, and I'll send you my E-Mail Address in a Private Message.
Jun 27 '09 #10

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

Similar topics

2
3163
by: Luther | last post by:
I want to create a form that searches a table. The hard part is this, I'd like to have the available records filtered based on combobox selections. For example, if this were a vehicle database, I might want to filter by AutomobileType, Year, Make, Model, Color. In this case it would work like this: First all of the records are available, that is, every kind of auto. So I select from my AutomobileType combobox "2003". Now I only have...
8
6541
by: dick | last post by:
I am just trying to print/report the results of a "filter by selection" which is done by right-clicking a form, filling in values, and "applying the filter." I have searched the newsgroups, and there are many examples. BUT, they fail sometimes. The techique is to pass the form's Me.filter as the "where condition" in a Docmd.openreport statement in code behind a "print button" on the form.
14
2376
by: Nothing | last post by:
I have a form that has a Tab Control on it. On one of the tab control pages, there are only 3 pages, is a combo box based on a field called departments in a table. When the user selects one of the departments from the combo box I want a sub-form to open on the tab control page based on the department selected. The sub-form is based on a query that pulls all employee data, so if a user selects admissions, I want the subform to open and...
0
1393
by: Wolfgang Kreuzer | last post by:
Hi, I am starting to migrate an Access 2.0 application to Access 2000 (I know it's not the latest version, but ist supported in our company). I found some funny behaviours where I could not find a solution in google groups. I retrieve data from sql server (2000) and created an access project. Form is bound to a view, in the form header there are two filter
2
1359
by: Anja | last post by:
Hi everyone, Well, kind of new to Access and VBA development in general. What I have a query that returns me all records based on a criteria. Now, I have a form where the user can choose this criterial via a combo box and I want a sub form to show up with the relevant records. I have 2 questions actually...
0
1900
by: Josetta | last post by:
This is for informational purposes...I had a problem and I thought it might help others in a similar situation. I hope someone, someday, finds this idea useful. I've garnered so much knowledge from this forum over the years, it's nice to present a solution that I couldn't find here. I have a form that my users wanted to filter, using the right-click Filter By or Filter Excluding, etc. I have a check box which my reports look up,...
7
6765
by: Katherine | last post by:
I'm trying to filter the records on the mainform (MailingList) of my database using a field contained in a subform (Donations). I was basing my code off Allen Browne's Access Tips page (here: http://allenbrowne.com/ser-28.html) since it has worked so well in the past. However, now I'm trying to filter by date instead of by a string or a number, and I'm getting nowhere. My goal is to have users type a date into the unbound combo box and...
6
4196
by: bammo | last post by:
MS Access 2003, Windows XP SP2, VBA I have a continuous form that allows edits and filters, but not deletions or additions. I filter the form based on combining selections the user makes in several combo boxes on the form. The filter is updated whenever the user changes his/her selection. My problem is when the user selects a filter option that is not present in the data. The filter works fine - no records are displayed; however, the...
1
6808
by: woodey2002 | last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on. My databse mostly includes bits of code for different examples. I have one last thing to finish. I am trying to create a search form that will allow users to select criteria from multiple sources eg ,multi select list boxes , combo boxes. I have a subform showing all the...
2
5280
by: sap01 | last post by:
Hi All, I want to display the data from a table by applying filter in the form. I want three combo box filter in the form. If I select all the three then it should display the data in the form from the table/query. Otherwise it should not. It should filter all three combo box at the same time in the form. I have only one table and lots of data in it. I want to display the records only when i select the item from all the three combo box. ...
0
9928
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9776
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10718
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10401
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9554
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7110
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.