473,414 Members | 1,627 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,414 software developers and data experts.

How do I open a filtered form based on a selection in a Combobox?

5
Ok, so im really new to access and programing in general, what i am doing is building a inventory(something simple),

the way ive got it set up now is, my entire inventory is in a combo box, and what i want to be able to do is select an item from the combo box and have it open a window(form?).

ok so i got this far, i have it Onclick open a newform, and that works fine but it returns everything in inventory, so what i need it to do is filter the new form based on what i click in the combo box, and for the life of me cant figure it out =(

I know this problem cant be hard im just to dumb to figure it out please help and thank you i hope i was clear enough :)
Aug 13 '09 #1
8 6733
(if opening a new form window is not a must for you, you acn look at the thread "limit browseable records by combobox).. There, you put a combobox in the header of the form and it will filter the content of the form..

So if you really want to open a new form, you could do exactly the same.
combobox_AfterUpdate -> open new form

In the new form, use the filter code (like in the mentioned thread) with the value of the combobox after update. I think this is the easiest way.. I'm sure ChipR will show up and give you more details if you didn't quite understand ;)
Aug 13 '09 #2
Jharp
5
well what i wanted to do was use the combobox for a generic list, then if you click on a item in the combobox it opens up a new form with all the detailed info on that item,

i have the combo box set up and when i click it opens up the form i want, but i cant get it to filter the new form based on what i click, it just lists every item =/
Aug 13 '09 #3
hi,

this is the thread i talked about:
http://bytes.com/topic/access/answer...cords-combobox

This is the code ChipR gave me:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbManufacturerFilter_AfterUpdate()
  2.     Me.Filter = "Manufacturer = '" & cmbManufacturerFilter & "'"
  3.     Me.FilterOn = True
  4. End Sub
So maybe you should use something like this for your popped up form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Me.Filter = "Manufacturer = '" & previousform.cmbInventory & "'"
  3.     Me.FilterOn = True
  4. End Sub
You replace manufacturer with the value you want.
Allthough, I'm not quite sure of the syntax of "form.object" I' m a noob too.
Aug 13 '09 #4
ChipR
1,287 Expert 1GB
That code will filter the form you are on, but in this case it would be better to filter the form being opened with the WhereCondition argument of the DoCmd.OpenForm. For example:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbItemNumber_AfterUpdate() 
  2.     Dim strWhereCondition as String
  3.     strWhereCondition = "[ItemNumber] = " & cmbItemNumber
  4.     DoCmd.OpenForm "frmViewRecords", , , strWhereCondition 
  5. End Sub 
Aug 13 '09 #5
Jharp
5
ah thats looking more like, unfortunately i dont have the project with me to try it out, but that looks like what i was shooting for
Aug 14 '09 #6
Jharp
5
i cant get it to work, heres what i have ill try to explain alittle how i have it setup
Private Sub Combo41_AfterUpdate()
Dim strWhereCondition As String
strWhereCondition = "[Combo41] = " & Combo41
DoCmd.OpenForm "stock1", , , strWhereCondition
End Sub

ok i have a table named "stock" it is my master list in my inventory its primary key is "old id" i then have a combo box named "combo41" which is based on table "stock" so it has everything.
I also made a Form named "Stocksub" which is formatted to show every item on its own page with more details
so what i would like is when i select an item out of the "combo41" i would like it to open "stocksub" and only display(or go to the right page) the item that is selected in "combo41"
i hope this makes some sense, and if you have a better way to set it up let me know :) thanks soo much for your help
Aug 17 '09 #7
ChipR
1,287 Expert 1GB
Your strWhereCondition needs to be in the form:
[tableFieldName] = value
So, it looks like it should be:
Expand|Select|Wrap|Line Numbers
  1. strWhereCondition = "[old id] = " & Combo41
Aug 17 '09 #8
Jharp
5
YES finally thanks soo much, i knew it was simple, i just needed someone who knew what they were doing, ty sir and have a great day :)
Aug 18 '09 #9

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

Similar topics

6
by: John | last post by:
Just a general question... I'm currently using a combobox that when updated, opens a form with its recordset based on a query using the combo box value as the criteria. I'm I correct in...
8
by: bbdata | last post by:
ok i have a problem here and not much time to play round. have a form bound to a table. one of the combos is bound to a field Agents. i have active and retired agents. thing is, i want to be able...
1
by: piet | last post by:
I have created a continues form, based on a query. In the header, there are some comboboxes that gives the user the possibility to make certain selections. Everytime a selection is made on a...
6
by: GSteven | last post by:
(as formerly posted to microsoft.public.access.forms with no result) I've created a continuous form which is based on a straightforward table (ex - customers - 100 records). On the form there is...
3
by: Eagle | last post by:
Hi, I've got an input form (frmInput) that can be accessed in two ways. A combobox on this form either gets filled in by a selection on an already opened form (frmBasic), or one can input a...
2
by: billypit | last post by:
Hi, I have one form in which I have one combobox and one subform. now when I am selecting value from combobox it will show details in subform by filtering from table based on my selection of...
3
by: Thelma Roslyn Lubkin | last post by:
I have a form whose rowsource is a single table, i.e. 'Datasystem'. I use a combobox to search for records in that table based on the value of a single field, i.e., 'systemname'. I use a...
3
by: Mack guy | last post by:
I'm working on an Access database and have a form with a combo box (a list of assembly plant locations), and I want a command button that will open the layout file for that plant. I've got ...
2
by: PTMech | last post by:
I have a tabbed subform (data sheet view) for which one of the controls is a combo box. It is based on a query that needs to be filtered by the same field data linking the main and sub forms. I...
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
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,...
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.