Filter On A Date AND A Combo Box

Sep 5, 2006

Hello everybody,

I have a problem.
I want to apply a filter on my form.When I filter on the combobox it works fine.
But when I filter on the date the form jumps into the error handler. Below is the code that I use for my filter:

Sub ApplyFilter()
Dim sFilter As String
sFilter = ""


'Filter on date
If Me.txtFilterDatumMelding = "" Or IsNull(Me.txtFilterDatumMelding) Or Me.txtFilterDatumMelding = 0 Then
If sFilter = "" Then
sFilter = ""
Else
sFilter = sFilter & ""
End If
Else
If sFilter = "" Then
sFilter = "[DatumMelding] = " & "'" & txtFilterDatumMelding & "'"

Else
sFilter = sFilter & " and [DatumMelding] = " & "'" & txtFilterDatumMelding & "'"
End If
End If

'Filter on combobox
If Me.cboFilterCallMelder = "" Or IsNull(Me.cboFilterCallMelder) Or Me.cboFilterCallMelder = 0 Then
If sFilter = "" Then
sFilter = ""
Else
sFilter = sFilter & ""
End If
Else
If sFilter = "" Then
sFilter = "[CallMelder_ID] = " & cboFilterCallMelder
Else
sFilter = sFilter & " And [CallMelder_ID] = " & cboFilterCallMelder
End If
End If

If Len(sFilter) > 0 Then
Me.Filter = sFilter
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
End If
End Sub

I hope that you gus can help me. Could it be that the filter is a string and the date filter field is a date??????

thanks in advance.

View Replies


ADVERTISEMENT

Forms :: Filter A Form Based On Date Selected From Combo Box

Dec 29, 2013

I have a form that is filter based on a combo box. I would like to add another filter for date. but the code I'm using for the first combo box doesn't work for date.

the code is:

Sub SetFilter()
Dim LSQL As String
LSQL = "select * from Preventive_Q_View"
LSQL = LSQL & " where Item_Name = '" & Combo206 & "'"
Form_Preventive_View.RecordSource = LSQL
End Sub

How do I modify this code to work with the date combo box? Also, is there a way to get both filters to work together, as in filter based on the first combo OR the second combo, OR both?

View 1 Replies View Related

Forms :: How To Filter Reports By Date Types In A Drop Down Or Combo Box

Jun 26, 2013

filter reports by specific date types in a drop down or combo box I would like the dates to be

Today
Tomorrow
The next 3 days and the next 7 days

i don't want a date picker or between dates I have tried searching but cannot seem to find an answer They are for my engineers, they want to know what callouts they have today or tomorrow or the next 3 days or this week.

View 3 Replies View Related

Modules & VBA :: Filter Records - Adding Unbound Date Listbox To Filter String

Feb 10, 2014

I'm trying to hash two scripts I've found into 1 functioning filter, however I'm still relatively new to vba and can't figure out how to get this working.

I'm trying to use Allen Browne's Search Criteria:

with another snippete of code I found here:

Code:
'Purpose: This module illustrates how to create a search form, _
where the user can enter as many or few criteria as they wish, _
and results are shown one per line.

[Code]....

It's the date part I'm having trouble with, the rest of the search criteria work fine without the date, but I can't get it working when I try to modify and merge the date sections of each code.

Also I'm using a listbox for the "Yesterday";"Last 4 days";"Last 9 days" and not a combo box.

View 2 Replies View Related

Problems Using A Combo Box To Filter Records In Another Combo Or A Sub-form

Nov 8, 2004

I have seen a few articles here and there on using a combo box to filter records in a sub-form and to filter records in another combo box, but I am not getting anywhere. I hope someone can belp

Exercise 1

For this exercise, I have the following tables:

tblClients containing client names
tblProjects containing some project details

I want to set up a simple form, so that the user can select a client name from a combo box on the main form which filters the project detail records in the Projects sub-form.
Once the user enters project details, I want this info as well as the selected ClientID to be fed back to tblProjects.


Exercise 2

I have the following tables:

tblProjects as above
tblWorkstream containiig names of workstreams and some other details.

Every project has one or more workstreams

I have a form where users will enter hours worked on each workstream. They will first select Project from a combo box on the main form. This should then filter records to be displayed in the Workstream Combo box, before they can then enter hours.



Please let me know if you need me to explain any part of this better.

Thanks in advance.

ps. I am a novice, so I'm hoping to do the above using default MS stuff, not with complex programming!!!

Thanks

View 14 Replies View Related

Forms :: How To Filter Combo 2 From Table After Select Value From Combo 1

Nov 5, 2013

i have a table with three column Named

1-State
2-City
3-Customer

on a form i m placing 3 combo box for each column how can i filter combo 2 from table after select value from combo 1

View 1 Replies View Related

Forms :: Setting Up A Combo Box To Filter Another Combo Box

Jan 27, 2015

I'm having a little difficulty setting up a combo box to filter another combo box. I've actually got one working but the second one is giving me all sorts of errors. On the attached database, there's a form called frmAddNewRecord. At the top of the form there's a combo box which allows you to select a name and another combo box beside it which acts as a filter so only names from a certain section are shown (working fine).

The subform which is attached to this form and contains the training details, has another combo box which allows you to select a job...I've tried to add a combo box beside this to filter it but I can't get it to work.

View 5 Replies View Related

Queries :: Date Filter - If Date Is In A Future Month

Apr 20, 2015

I've two fields to work with:

[Date of Device]
[DischDate]

If i was explaining it, it would be as follows:

If [DischDate] Is in the next month after [Date of Device] then Y else N.

to add for example if the [Date of Device] is April 2015, and the [DischDate] is also April then i'd expect a N answer

to add for example if the [Date of Device] is April 2015, and the [DischDate] is May then i'd expect a Y answer

View 2 Replies View Related

Combo Box Filter

Apr 23, 2006

Hi All,
Just after a code or way to filter client details via a combo box.
Basically select combox drop down menu select the sales rep then it filters by sales rep and shows only the clients for that sales rep. I can get it to filter but it does the first client of that sales rep but not the rest.

Thanks
Karl

View 4 Replies View Related

Combo Box Filter

Jun 6, 2005

I have two combo boxes, Company Name & Name. The data that is selected is used to run a query from a button. However i would like to set it that if the user (but not required) selects the company name then only the names of the people belonging to that company appear, but if no company is selected then all the names for every company appear.

Can anyone make a suggestion as to the best way to go about this.

Thanks

View 11 Replies View Related

Combo Box And Filter - Please Help

Nov 12, 2004

I've read several threads about one combo filtering a second combo on a form, but can't seem to find a similar enough situation. Can you please advise on the following:

I have a form based on a query containing a whole load of fields from several tables. In particular the query contains a field called WorkstreamID from tblWorkstream.

Each tblWorkstream record has a Workstream ID, Workstream and foreign key called Project ID from tblProjects.

I want my form to have two combos: one for Projects (unbound) which filters the combo for Workstream (bound to the underlying query of the form)

How do I do this?

Please bear in mind, I am not an expert!

Thanks in advance

Sunil

View 14 Replies View Related

Filter By Combo Box Entry

Dec 14, 2007

Hi,

I have a form with a list box that is filtered by the entry made into a combo box. It works fine except that I want an option which shows all records in the list box. I tried using the formula below in the query criteria for the list box but it returns no records when I select All in the combo box. Why won't it work? Is there a better way to do this? Can anyone help?

IIf([Combo32].[Value]="All",Like "*",[Combo32].[Value])

View 4 Replies View Related

Combo Box (Filter By Selection)

Jul 24, 2005

hi all,
another quick question (last one for awhile I promise) but is there a way to add an option to a combo box (Filter by Selection) and Remove/Filter sort without right clicking on it?
cheers,
Andrew

View 1 Replies View Related

Using A Combo Box To Filter Results

Sep 2, 2005

I have a table that has the fields Scheme no, Title, Area, Pole No, Rate No, Description, Quantity. Each Scheme No has a number of Poles attached to it, and subsequently each Pole has a number of different rates attached (eg of table shown below)

On the corresponding form I have ID No, Title and Area in the Form header as they are the same for all fields. Therefore in the detail section I want the rest of the fields. The problem I have is I want the user to be able to choose a pole no from a combo box and show up only the corresponding rates to that pole. So for instance below the user could select in the combo box Pole no YP08 and only the rates used on that pole would show up (in this case it would be just HV99 and its description).

SchemeNo.....Title......Area......Pole Number.....Rate......Description etc
001...............xxx........UK...........YP26.... .......LV01..........xxxxx
001...............xxx........UK...........YP26.... .......HV89..........xxxxx
001...............xxx........UK...........YP08.... .......HV99..........xxxxx
001...............xxx........UK...........YP09.... .......YG67..........xxxxx
001...............xxx........UK...........YP99.... .......LG45..........xxxxx

I hope this makes sense to you. Any help with how I can set up this combo box would be greatly appreciated

View 11 Replies View Related

Recordset Filter Combo Box

Oct 18, 2005

Hi There. Im Trying To Filter Records Through A Combo Box Which Is So Far So Good. However What I Would Like To Do Is Select The Records Through The Combo Box And Have It Return And Populate Only Those Records. Has Anyone Got Any Suggestions To This?
Ive Attached The Sample Database Im Working On.

Cheers

View 3 Replies View Related

Error In Combo Filter

Dec 11, 2005

Pleae take a look at the attached database, open frmUpdate and select an item in Group1.
I get a message box "Enter parameter Value" - Group1.

After I click OK, sometimes I get a run-time error, usually everything works fine until the form is reopened.

Can anyone see my problem.



thanks
Steve

View 3 Replies View Related

Filter A Subform Using A Combo Box

Mar 9, 2006

I have a form with a combo box on it.

I want to use the combo box to query a subform.

So basically when you click on the record in the combo box it will filter the subform based on the selection.

Is there is a simple way or do I need to be more specific about the requirements ?

Any help would be greatly appreciated.

Domble

View 2 Replies View Related

An Issue With A Combo Box Filter

Apr 27, 2006

I am having an issue with my combo box filter, this set of code dynamically updates the combo box to add any new user and select the accounts that are assigned to them. Given everything works and everything filters, the problem is merely a cosmetic one that has to be fixed.

Basically what is happening is the Combo Box displays "*", and "All Records" but we can not get it too show the "Unassigned" -- any idea why?....

View 1 Replies View Related

General :: Filter Name In Combo Box

Jan 19, 2014

I have at present 2 combo box's that filter, now....... the 1st combo box is a drop down value list that will filter the OPOwner (persons name) for example there are 3000 records and 5 OPOwners, I can for now filter my name in cboOPOwner combo box.

The 2nd box (drop down list) is Status which would be "New";"Open";Pipeline";"Lead" ect...

If I filter my name it brings up all records related to my name and the when I want to filter status it will bring up all records relating to say 'Pipeline' however it will bring everyone's ;Pipeline and not just mine.

What I want is to filter my name in the OPOwner combo box and once all records are filtered in my name then in the status combo box filter what ever I want to look at. example what I want to filter - 'Filter Neil' then 'Filter Pipeline, or filter Lead or New'.

This is the code I have in both combo's....

Private Sub cboOPOwner_AfterUpdate()
If Nz(Me.cboOPOwner.Text) = "" Then
Me.Form.Filter = ""
Me.FilterOn = False
ElseIf Me.cboOPOwner.ListIndex <> -1 Then
Me.Form.Filter = "[OPOwner] = '" & _
Replace(Me.cboOPOwner.Text, "'", "''") & "'"
Me.FilterOn = True

[Code] ....

View 14 Replies View Related

Modules & VBA :: Use Combo Box As Filter

Mar 19, 2014

I am trying to edit the below code to use 'Form_Select_Batch_Number_Form.Combo9.Value' as the combobox value to filter the records in 'Form_ Remitter_DB_Entry_Form'. I am trying to get the filtering to occur when a button on Form_Select_Batch_Number is selected. Below is my attempt to create the button to accomplish this but it is not functional and needs some work.

Code:

Option Compare Database
Private Sub Command0_Click()
DoCmd.OpenForm "Blank Form2", windowmode:=acDialog
Dim MyValue As String

[code]....

View 3 Replies View Related

How To Use A Combo Box To Filter A Table

Jun 16, 2014

I am back with another question about Access 2010. I would like to filter a table by using a combo box.

I have several columns in the table, and I would like to filter them by their departments (there are several users in each department)

I have tried using the combo box wizard and select " I would like to search records based on the values in combo box" but the problem is that the department shows up as many times as it is in that table.

I came across another solution which was to create an unbound combo box and link it with the query. and the department criteria would be the following:

[Form]![NameOfTheForm]![NameOfTheCombobox]

but it did not work either.

View 1 Replies View Related

How To Create Combo Box Filter

Dec 7, 2012

I`m using access 2010 version, i have one table(Customer) which has one-to-many relationship to the table(Order), so the Order table contains many records from one single record in Customer. How to create a combobox that filter and show how many orders the Customer has. Example:

Table(Customer)
Line 1 - Crystal

Table(Order)
Line 1 - Water
Line 2 - Cookies
Line 3 - Pens

View 4 Replies View Related

Combo BOx Filter Issues - Can Get Passed It

Jan 15, 2008

Okay I created a database that I am going to use to collect data about a study we are doing.When a participant is added to the database on the main (Participation Details form), it automatically generates an ID and creates a record in a second table/form - a questionnaire (i.e. Athens Questionnaire) that the participants fill out preserving the ID number that was created in the participation details form (I have been able to achieve this).However what I wanted to do next is be able to filter the Athens questionnaire using a combo box which contained all the participant's ID's.I was able to create the combo-box and populate it with the ID's using a query and did not put a control source on it (i used =tblAthens.ParticipantID ....) iand created a sub-form that contained the questionnaire. I did this by creating the questionnaire in a separate form called frmAthens_sub and dragging it from the "explorer window" into my open Athens Questionnaire form. However when I attempted to place code in the "After Update" field of the combo box I keep getting errors and I am not sure why.The code I am using is:Option Compare DatabaseSub SetFilter() Dim LSQL As String LSQL = "select * from tblAthens" LSQL = LSQL & " where ParticipantID = '" & cboSelected & "'" Form_frmAthens_sub.RecordSource = LSQL End SubPrivate Sub cboSelected_AfterUpdate() 'Call subroutine to set filter based on selected ParticipantID SetFilter End SubPrivate Sub Form_Open(Cancel As Integer) 'Call subroutine to set filter based on selected ParticipantID SetFilter End SubIt is highly possible that I am just not doing something right as this is the first time I have used sub-forms. I tried to attach a copy of the database but cant get it below the max. The error seems to be coming from this line --> Form_frmAthens_sub.RecordSource = LSQLIs there an easier way or alternative code for filtering a sub-form from a combo-box?

View 3 Replies View Related

Filter Subform Based On Combo Box

Dec 13, 2005

Hello everyone!

I think I am asking the impossible, but can't think why it can't be done!

Here's the dilema:

I am working with an unbound form to search a Mobile Register.

On the form I have an unbound combo box which looks up User details from a table (LKP_User).

When I select a user, I want the subform below to filter all the details for that user and show me which mobiles they have.

PROBLEM:
Combo Box has 3 fields, User_ID, User, Dept_ID. User_ID is bound column but not displayed in combo (only User) is displayed.

I need to link the User_ID with the User_ID on the subform, but don't know how to tell it to look at column 1 of the combo box.

Can anyone point me in the right direction? Do I need some fancy code to get this to work?

Cheers in anticipation
NKA

View 6 Replies View Related

Help Using A Combo Box And Button To Filter Data

Oct 11, 2006

Hi there!

I am pretty new at this so please bear with me :confused: (like that isn't said a thousand times!). I am creating a small database to track task data (manpower tracking basically) where I have the following fields:

Customer
Functional Group
Task Status
Task Name
Task Description
WO #
Funded Hours
Notes

I would like to create a combo box where the user can select the customer (I have 124 records in total, 15 unique customer names) and all tasks relating to that customer are filtered directly in the Form by clicking a single button to do the filter.

I don't want to create dozens of tables and forms to flip through and such (users need it as simple as possible). I have created queries but the only way I have successfully filtered each customer is via buttons...but 15 buttons to filter each individual customer is a pain in the butt, so any help would be REALLY appreciated.

Please let me know if I haven't explained this clearly enough! :)

Thanks!

View 10 Replies View Related

Populating A Text Box Using Combo Box Filter

Nov 18, 2004

Hello,
This is my first time posting here and I hope someone can help me. I am not experienced with coding in access and only recently started using forms.

I am trying to create a text box that automaticly fills in once a selection is made in a combo box.

There are only 2 tables and 1 form I am working with. Table 1 has columns "code" and "bu". The second table has several columns, all blank, that the form fills in.

The combo box is working correctly, it displays all the "code"s. Once the code is selected I would like a text box to display the "bu" column.

Any suggestions are much appreciated.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved