My Date Search isnt showing me null values for my date fields (1 Viewer)

Dreamweaver

Well-known member
Local time
Today, 01:39
Joined
Nov 28, 2005
Messages
2,466
All the templates use the same search and print screeens, I had to limit the downloads as people were coming on and downloaded everything.
 

June7

AWF VIP
Local time
Yesterday, 16:39
Joined
Mar 9, 2014
Messages
5,470
It displays only one record because that is the criteria provided. You have restricted to a single unique ID.

For an example, if you want to filter by value in status combobox:

If Not IsNull(Me.cbotasktype) Then strWhere = "Status = '" & Me.cbotasktype & "'"
DoCmd.OpenReport "DemoReportSubform", acViewPreview, , strWhere

Use Allen Browne's code as an example to dynamically build multiple filter criteria. Modify to suit your database.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 20:39
Joined
May 21, 2018
Messages
8,528
I wish you would have read my thread. My code makes it very easy to do multi control filters. It is easier and more flexible than any other code out there. Here is all the code that is needed on your form.
Code:
Private Sub cmdClear_Click()
' this is to clear the buttons
  Me.OrderDateFrom = Null
  Me.OrderDateTo = Null
  Me.cbotasktype = Null
  Me.searchme = Null
  Me.Filter = ""
  Me.FilterOn = False
End Sub

Private Function FilterForm()
  Dim frmFltr As String
  Dim toFltr As String
  Dim betweenFltr As String
  Dim statusFltr As String
  Dim combineFltr As String
  Me.Filter = ""
  frmFltr = GetFilterFromTextBox(Me.OrderDateFrom, sdt_date, "startDate", flt_GreaterThanOrEqual)
  toFltr = GetFilterFromTextBox(Me.OrderDateTo, sdt_date, "startDate", flt_LessThanOrEqual)
  statusFltr = mdlControlFilters.GetFilterFromSingleListOrCombo(Me.cbotasktype)
  combinefilter = mdlControlFilters.CombineFilters(ct_And, frmFltr, toFltr, statusFltr)
  Me.Filter = combinefilter
  Me.FilterOn = True
End Function

Private Sub Command106_Click()
  DoCmd.OpenForm "dateSearch", acPreview, , Me.Filter
End Sub
 

Attachments

  • MajP_IT_Tasks_Log.zip
    413.9 KB · Views: 99

ashah08

Member
Local time
Yesterday, 20:39
Joined
May 1, 2020
Messages
35
Hi @MajP

Thank You so much for making changes to my code and helping me out, i just cant thank you enough.

I still have 1 issue that when i click on report it only shows me completed task and doesnt show me in-complete task.
is there a work-around for that ?

Thank You once again

I really appreciate your help





I wish you would have read my thread. My code makes it very easy to do multi control filters. It is easier and more flexible than any other code out there. Here is all the code that is needed on your form.
Code:
Private Sub cmdClear_Click()
' this is to clear the buttons
  Me.OrderDateFrom = Null
  Me.OrderDateTo = Null
  Me.cbotasktype = Null
  Me.searchme = Null
  Me.Filter = ""
  Me.FilterOn = False
End Sub

Private Function FilterForm()
  Dim frmFltr As String
  Dim toFltr As String
  Dim betweenFltr As String
  Dim statusFltr As String
  Dim combineFltr As String
  Me.Filter = ""
  frmFltr = GetFilterFromTextBox(Me.OrderDateFrom, sdt_date, "startDate", flt_GreaterThanOrEqual)
  toFltr = GetFilterFromTextBox(Me.OrderDateTo, sdt_date, "startDate", flt_LessThanOrEqual)
  statusFltr = mdlControlFilters.GetFilterFromSingleListOrCombo(Me.cbotasktype)
  combinefilter = mdlControlFilters.CombineFilters(ct_And, frmFltr, toFltr, statusFltr)
  Me.Filter = combinefilter
  Me.FilterOn = True
End Function

Private Sub Command106_Click()
  DoCmd.OpenForm "dateSearch", acPreview, , Me.Filter
End Sub
 

ashah08

Member
Local time
Yesterday, 20:39
Joined
May 1, 2020
Messages
35
Hi @MajP

there is one more thing that i just noticed.
when in my date search form, if i put my date From and Date To then i am able to create a report but when i use my third filter which is category i.e complete or in-complete then it works fine on my form but when i hit report it force closes my database.

Any idea, why is it doing that ?

Thank You
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 20:39
Joined
May 21, 2018
Messages
8,528
Sorry about that. Try this. I had a very strange error and not even sure why it worked at all. Instead of having
Docmd.openreport I had docmd.openform. But I still cannot figure out why it worked at all. FYI do not have forms, reports, and tables with the same name. The normal convention is
tblName
rptNameOfReport
frmNameOfForm
cboNameOfComb
txtBxNameOf..
etc.
You do not have to mirror that, but pick something to avoid these simple errors. Also no spaces in any names.

Also there is a lot of weird issues with this DB, you have a lot of leftover junk.

1. Create a brand new blank db.
2. Import into it just the tables you plan to use
3. Do a compact and repair
4. Now import the remaining objects
5. Go into vba and do a debug/compile. Fix all the issues where it breaks.
6. If necessary add in new referernces.

This is a good process to repeat during development, to keep everything nice and clean.
 

Attachments

  • MajP_IT_Tasks_LogV2.zip
    423.7 KB · Views: 89

ashah08

Member
Local time
Yesterday, 20:39
Joined
May 1, 2020
Messages
35
Sorry about that. Try this. I had a very strange error and not even sure why it worked at all. Instead of having
Docmd.openreport I had docmd.openform. But I still cannot figure out why it worked at all. FYI do not have forms, reports, and tables with the same name. The normal convention is
tblName
rptNameOfReport
frmNameOfForm
cboNameOfComb
txtBxNameOf..
etc.
You do not have to mirror that, but pick something to avoid these simple errors. Also no spaces in any names.

Also there is a lot of weird issues with this DB, you have a lot of leftover junk.

1. Create a brand new blank db.
2. Import into it just the tables you plan to use
3. Do a compact and repair
4. Now import the remaining objects
5. Go into vba and do a debug/compile. Fix all the issues where it breaks.
6. If necessary add in new referernces.

This is a good process to repeat during development, to keep everything nice and clean.


Hi @MajP

Thank You so much.
ill keep your information in mind, when i create a new database.

1 last question my searchme textbox doesnt work.
i did put this code below on click event

Private Sub searchme_Click()
Dim sFind, sField, sFilter As String
searchme.SetFocus
sFind = Nz(searchme.Text, "")
If Len(sFind) > 0 Then
sField = "[Title]" 'Replace with a real field
sFilter = sField & " Like '*" & sFind & "*'"
Me.Filter = sFilter
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
End If
searchme.SetFocus
searchme.SelStart = Len(sFind) + 1
searchme.SelLength = 0
End Sub

but this is not allowing me to search ?
is it because all the filters are off when form loads or am i doing something wrong in here?

Thanks once again
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 20:39
Joined
May 21, 2018
Messages
8,528
Make sure in the onchange property it has the word [event procedure]
 

ashah08

Member
Local time
Yesterday, 20:39
Joined
May 1, 2020
Messages
35
Make sure in the onchange property it has the word [event procedure]


Hi @MajP

You are a Life Saver!!!!!!!!!!!!!!!!
Thank you so much

i wish i could connect with you on any another other social media.

Thanks once again!!
 

Users who are viewing this thread

Top Bottom