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

Query Form with optional criteria

I have a table [HIP-MSP-Filter] with the following text fields
Status
group_type
query_hits
PLATFORM
Group_No_7
Group_No_3

I need to be able have a form which uses combo boxes as required and optional filter criteria and then displays the results in an updatable subform.

[Forms]![frm_update_&_review]![cbo_Status] Required Filter

[Forms]![frm_update_&_review]![ cbo_group_type] Optional Filter, cbo needs to be grouped

[Forms]![frm_update_&_review]![ cbo_query_hits] Optional Filter, cbo needs to be grouped

[Forms]![frm_update_&_review]![cbo_ PLATFORM] Optional Filter, cbo needs to be grouped

[Forms]![frm_update_&_review]![cbo_Group_No_7] Optional Filter, cbo needs to be grouped

[Forms]![frm_update_&_review]![cbo_Group_No_3] Optional Filter, cbo needs to be grouped

I have already tried the below which did nothing

Private Sub cbo_group_type_AfterUpdate()
If IsNull(Me.cbo_group_type) Then
Me.FilterOn = False
Else
Me.Filter = "group_type = """ & Me.cbo_group_type & """"
Me.FilterOn = True
End If
End Sub

Any help is greatly appreciated.
Jul 6 '09 #1
1 2478
Lysander
344 Expert 100+
If I understand this correctly, you are opening a form, with a sub-form.

The main form is used to select what filters to apply to the sub form.

What I do is have the sub form disabled, and then when all the combo boxes have been selected, change the recordsource of the sub form and enable it.

You could do this in the after_update event of the last combo box, or have a seperate button, say, 'Filters Selected' that applies the filters you want.

An example is below.
Subform is called "fsubPostPregnancyDataEntry"
Expand|Select|Wrap|Line Numbers
  1. strSql="Select * from MyTable Where "
  2. strSql=strSQL & " group_Type='" & cboGroupType & "'"
  3. strSQL=strSQL & " AND nextfield=" & cboNextOne & "
  4.  
  5. etc
  6.  
  7. Me.fsubPostPregnancyDataEntry.Form.RecordSource = strSQL
  8. Me.fsubPostPregnancyDataEntry.Form.Enabled = True
  9.  
Jul 8 '09 #2

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

Similar topics

3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
2
by: Pete | last post by:
Before I get started with the question, does anyone have a (single) good book recommendation for database design? Not an Access-specific book, but something geared toward helping me figure out...
1
by: Michael Israel | last post by:
I am new to Access. I have a form with a single record. The keyed field is PropID (number). I want to run a query from the form that will have the current value of PropID be the variable in the...
4
by: paii, Ron | last post by:
I am trying to use the following "Elookup" function on a query that gets 2 parameters from an open form. ?eLookup("", "qryWOLPCMatEst") Returns the following error. Too few parameters....
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
1
by: lucazz | last post by:
I have a form with 2 comboboxes (dept, section) and a listbox (employees). Listbox is based on a query with 2 criteria (Forms!Form!Dept and Forms!Form!Section). Whenever I choose values in both...
2
by: Stephan | last post by:
Hi all, I am looking for help regarding my query. I have a table containing different information about meetings such as date, topic, and 3 separate keywords assigned. Now, I would like to...
2
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and...
3
by: bob laughland | last post by:
Hi All, I have another SQL question, and this one is going to be difficult to explain. I have a table like this rowid name changed 1 a 1 1 ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.