How To Set a Filter Using an Item Selected from a Combo Box?

Hi, everybody

Please show me how to use the item selected in a combo box (cb1) to filter what is displayed in a second combo box(cb2).
Let say, i have a table called tbProduct which includes ProductID, Name, Model, Type1, Type2,...

ProductID Name Model Type1 Type2
01 Ringset TS50 TF60 Aricul
02 Ringset TS60 TF70 Aricul
03 Piston 3T 4T Margin
04 Piston 2SM 3SM Margin

Cb1: should be Name of product (Bound column1 (ProductID)
Cb2: should be Model which has been filtered from the Name of Prouduct as i have selected from cb1.

Forgive for my poor english.

Thank you very much
HAPPY NEW YEAR ALL OF YOU


Post your answer or comment

comments powered by Disqus
I have code that I would like to set a variable in an open form from another open form. I get an error when using the code pasted below:

"Application Defined or Object Defined Error.."

Can someone tell me if you can set a variable dim'd in another form and if so what the syntax is?

Thanks..
=====================================
This part of the code is where it is erring out:

frm.str_entry_type = str_fra_val_proc_frm

I want the variable that is dim'd in the frm_pr_proc_sel_req to be set to the value of the variable in the current open form (named frm_entry_type)

=====================================
CODE:

Dim frm As Form
Set frm = Forms("frm_pr_proc_sel_req")
Dim str_msg_1 As String
Dim str_msg_2 As String
Dim str_fra_val As String
Dim str_fra_val_proc_frm As String 'for use in setting the value of the form: frm_pr_proc_sel_req varible so can decide if requester wants se or pr record..

If Me.fra_entry_type.Value = 1 Then
str_fra_val = "Profile Entry"
str_fra_val_proc_frm = "pr"
ElseIf Me.fra_entry_type.Value = 2 Then
str_fra_val = "Special Exception Entry"
str_fra_val_proc_frm = "se"
End If

str_msg_1 = "You have selected " & vbCrLf & vbCrLf & UCase(str_fra_val) & vbCrLf & vbCrLf _
& "as the Entry Type. If This is correct, click YES. Otherwise click NO and reselect"

str_msg_2 = "Please re-enter a new entry type"

If fcn_confirm(str_msg_1) = True Then
frm.str_entry_type = str_fra_val_proc_frm
DoCmd.Close
Else
MsgBox str_msg_2
Me.fra_entry_type = Null
End If

Hi all,

Can some one help me with how to set a default text on a combo box whose record source is set to a query?

I have a form with two combo boxes. The first combo box’s record source is set to the following query:

SELECT chrCategoryID, chrCategoryName
FROM tblGuarCategory;
My 2nd combo box will list all the items based the category I select on the first combo box.

But when the user opens the form, instead of showing both combo boxes blank, I would like to display the following text:

Combo Box1: Select a category
Combo Box2: Select an item…

I tried to use the combo box’s Default Value property like = “Select a category”. It didn’t work. I am not sure what is missing here. I appreciate your help.

Good,
I already created my query table and I would like to know on how to set a query field [Section] in a combo box in my form. The combo box will used to filter records (based on Section) in my tblEmployee and be able to print that filtered data using my report form.

Please help.

Hi how are u all?
I have a subform which has multiple records, i wanna write code which reads the records one by one, in other wards, i need a loop & an array to read it, but i donno how to read (a record) using an array in Access.

Anyhelp is highly appreciated

Hello everyone,

I am using the following code (which i got by using the search function in the website":


	Code:
	Public Function BackupCopy() 

'This function will allow you to copy a db that is open, 

'You must set a reference to the 'Microsoft Scripting Runtime' for the CopyFile piece to work! 

Dim fso As FileSystemObject 

Dim sSourcePath As String 
Dim sSourceFile As String 
Dim sBackupPath As String 
Dim sBackupFile As String 

sSourcePath = "C:Database" 
sSourceFile = "MyDB.mdb" 
sBackupPath = "C:DatabaseBackups" 
sBackupFile = "BackupDB_" & Format(Date, "mmddyyyy") & "_" & Format(Time, "hhmmss") & ".mdb" 

Set fso = New FileSystemObject 
fso.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True 
Set fso = Nothing 

Beep 
MsgBox "Backup was successful and saved @ " & Chr(13) & Chr(13) & sBackupPath & Chr(13) & Chr(13) & "The backup file name is
" & Chr(13) & Chr(13) & sBackupFile, vbInformation, "Backup Completed" 

End Function

My question is where and how to set a reference to the 'Microsoft Scripting runtime'?
Iam a beginner so please bear with me..

Di7bash

Hi everyone, I am new in using access 2010. It would be very great if u can help me.

I want to ask how to create a filter in forms.
For instance, I want to create a textbox for criteria input. After clicking a button, data can be filtered by the value of the criteria input and shown out.

Can I do this in access? How to achieve this?
Thanks so much!!!!!

I have a VBA code as below. How to set a query which cannot delete, but can add and update ?

Private Sub cmdEdit_Click()
DoCmd.OpenQuery "V_Master_Drawing_Assembly", acViewNormal, acEdit
End Sub

Hello everyone,
I just want the code for Filtering the values of one combo box in sub form from selecting an item of another combo box in the main form.Please do reply as soon as possible in the MS Access 2007 format.

Hi,
Am now creating a form in ms access, but I got stucked...
I would use this form for rather reporting data (not for adding data into the database).The form is linked to one table only (I have imported the database from excel), containing columns like customer name, customer category, month, product name sold, volume sold in qty, volume sold in €....etc.
What I would like to get with the help of this form is the following:
-first I select from eg: customer category X
-in the field, "customer name" only those customerts are visible, which belong to customer category X, ----> I select customer A
-than, in field "product name" only those items are visible, what "customer A" has purchased, and I choose "product 1"
...
after I set up all filters I wanted in all fields, press the buttom eg "export to excel", and all data (based on the selections were done in previous steps) will be loaded into a new excel file.

What I do not know how to match one field with the other, how to set up the condition if Customer X is filtered, only relevant products will be indicated.
At the moment despite of selecting "Customer category X", all existing customer will be shown in "customer name", not only those ones have customer category X in the table.
I would appreciate any help!

Thanks in advance!

Hi,

I think this may be a union query solution but I cannot work out how to do a union query...

I have two queries exactly the same except one has Budget Amount the other has Actual Amount

I want to join the two together in a new query that displays everything...

Currently using a select query I can play around with the joins and either get all cost centres with budget or all cost centres with actuals

But if i want a list that shows all cost centres regardless if they have an actual without a budget or a budget without an actual or indeed they have both...

Help???

Hi,

I am a beginner in Access and I want to create a filter with a dropdown list so that I can easily pull up details for my daily report. Since I am a beginner, I hope you can help me by giving detailed step by step instructions on how to do it in Access. I am using a template in Access that I edited and I am hoping that I can add a new filter with dropdown list for easy referrence and viewing. That would save me a lot of time since I am integrating 3 reports in my access database. I have been looking for tutorial for the instructions but to no avail.

Thanks!

Hey,

I want to set a value of a textbox to a query but not sure how. I tried to build an expression but I got the #Name? displayed inside the textbox. I wanted the value to display as soon as the form opened and change every time a value changes inside the tables

Any advice would be great.

Thanks
Chris
________
buy cannabis seeds

Hello

i am working on a project where i have a table named

"employee info"

in which the fields are

"employeeid" "employeename" , "employeesalary" ,

and also have another table named

"employeesalary"

in which the fields are

"employeeid" that is linked with the "employee info" table. and an other field named "salary"

where i use to enter employee id and the information related that id is automatically generate from the table named

"employeeinfo"

now i am facing problem that i want to set a field named

"employeesalry" as default value of the field named

"salary"

and also that default value can be editable or changeable manually when i want to change in future.

plz tell me solution as soon as possible

thanx in advance

I'am sitting here scratching my head in total confusion.

I have an action button in a form that runs a macro. This macro is a one-step macro to close the form I have open.

When I click the action button, the macro dues not run. An error message pops up that says:
This action can't be carried out while processing a form or report event.

If I was to just have the form open and run the macro button straight from the macro objects, it closes the form, no problem.

Can anyone provide me some guidance on how to close the form using a macrobutton?

Thanks all!

Nick

Hi,

Can any one pleae tell me how to call a module through macro? i have the below function in my module but not able to run using the macro

Public Function SendSheet(strTQName As String, strSheetName
code
End Funciton

Thanks,
Binu.

Hello all.
I have a couple of doubts.
first is how to set page margins using VBA code.
second is how to open report in invisiblw mode in design view.

i am using Access 2000

thank you in advance.

piyush

I would like to create a filter on a form that will show records based on my selection from drop down box (combo box) and show the data in a subform in Datasheet view that I query.

How do I do this? Please help thank you.

Please excuse my ignorance but I dont know how to use a front end form on access adp to create a new record on the sqlserver.

I have made a connection via odbc and can see the tables on access and view them. However when I create a new record on the form and use DoCmd to save the record it appears to update the table showing in access (as dbo.tbl) but when I go back to the server the new record does no show. I did not receive any access or sqlserver errors and recieved the MsgBox message saying new record created.

Not having worked with sqlserver before, is there something I am missing. I was assuming that because my access front end could see the tables, it would be able to create, update and delete using the DoCmd available in access.

Could someone please advise.

Hi All,

I am a compleate new user so please be as kind as possible especially with the technical talk!!

I work at a sawmilling company and am in the process of making a basic database to enter in and then to look over our current stocks.

I have a form (Stock Filter) that has eight unbound combo boxes that lookup the values in eight seperate product description tables.

These combo boxes and there related product description tables are called:

Grade
Treatment
Location
Drying
Finish
Nominal Width
Nominal Thickness
Actual Width
Actual Thickness

The subform (Stock Filter Subform) is a Query that shows each pack of timber we have in stock, the product description information from the above tables, length information plus some general summing information.

Basically I want a "Filter by Selection" on each combo box. When the user chooses the value from each combo box the subform query is filtered to only show the records that corresond to that choice. He or she might filter by "GRADE" and then by "ACTUAL WIDTH" etc and so on.

I presume I also need a command button that removes all the filters at once so the user can start again and would also like a command button that sends the filtered information to a report that we can print, fax or email to customers

I have read and re-read the manual, looked at help and searched the forum but just can't get it to work. Everything I have created so far has been through the use of wizards and I draw a blank on macros and codes.

Can any one give me a step by step on how to set this up?

If I can get one combo box to work, In can follow copy the information for the other boxes.

Really appreciate your help.

JohnG From New Zealand.

Hi there,

I tried to set a default value for a lookup list in a table by entering a value in Design View--General--Default Value. But that default value doesn't come out.

Does anyone know how to do it?

Thank you very much!

Hi All,

I was wondering if anyone can help please. I am trying to set a list of values for a Combo box based on a selected value in another Combo box. I found good example here :
http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=41120

posted by Lacer and you can see the database called dyncombo.zip

All the instruction is there. The problem I have is when i change the form "chooser" to datasheet as defaul view from design, then the combo boxes don't show me the list values in stored in the form. Can anyone help what is wrong please?


Thank you for your help

hi i am not good at programming and it was 5 years ago when I did VB.. please find an attachment .jpg called "Student-Form.jpg".

at the moment, when the user change either "Gender" and "Nationality" on the left side, the "Save" button at the bottom of the form will be available. if you just browse the information, this button is always greyed out.

this form is created by someone else who i don't know. i now added two subforms on the right top. it is currently looking ugly with the line.. (i dont' know how to get rid of this.)

i can click those combo box, i.e., "Enrolment Status", "Campus", and "Programme", and change to some other options. however, the "Save" button is still greyed out.. i have been told that i have to code for this subform.

i know this is so rude to ask, but can any one please give me any links i should look at, or some basic code that i could use for it.

how can i tell the main form (parent form? "Student Details" tab) that the subform ("Enrolment" and "Intake" dates info) has been changed?

i deeply appriciate your help.
Gaufres

Hi,

I have a text box and a button. The user types an order number into the text box, pushes the button and the VB code finds the appropriate record and makes it the active record. Now, how to provide a user with an error message if the record was not found (because he typed in a non-existing order number)? Could you, please, complete my code? Here is my code:

Private Sub SearchButton_Click()
Dim CheckLength As String
Dim ErrorText As String
' Check if the user has entered an order number
If Nz(Me.SearchBox.Value) < "0" Then
ErrorText = MsgBox("You didn't provide an order number", vbOKOnly, "Error!")
Else
' The order number must have 13 characters long
CheckLength = Me.SearchBox.Value
If Len(CheckLength) = 13 Then
Me![Kits Subform].SetFocus
Me![Kits Subform].Form.KitOrdNo.SetFocus
Application.Echo False
DoCmd.FindRecord Me.SearchBox.Value, acEntire, False, acSearchAll, False, acCurrent, True
Application.Echo True
' An error message should be showed here if there was no match.
Else
ErrorText = MsgBox("Order number must consist of 13 characters", vbOKOnly, "Error!")
End If
End If
End Sub

Thank you,
Attila

Hi,

I add a new user through the menus

Tools -> Security ->User and Group Accounting -> users -> new

But I do not know how to set a password to the new user.

Please help me to find out this

Thanks

Mark


Not finding an answer? Try a Google search.