Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Issue (Strange)

Status
Not open for further replies.

anon47

Programmer
Nov 28, 2006
80
US
I have this code in a value list drop down menu and it works fine on another form but I can get it to work on client form now if the record is filtered the show all records works to unfilter the records. ANY HELP!!

Private Sub myComboBox_Change()
Dim sFilter As String

Select Case myComboBox

Case "Show All Records"
sFilter = True

Case "View By Days"
sFilter = "(((Date)>Date()-Days))"

Case "View By Called"
sFilter = "Called = TRUE"

Case "Requested Call Back"
sFilter = "RequestedCallBack = TRUE"

Case "Help Needed"
sFilter = "HelpNeeded = TRUE"

End Select
Me.Filter = sFilter
Me.FilterOn = True
End Sub
 
Now it gives no error it just doesn't filter the record but it will filter the record if you filter it with a button on click method.
 
What about this ?
Private Sub myComboBox_Change()
Dim sFilter As String
Select Case myComboBox
Case "View By Days"
sFilter = "[Date]>Date()-Days"
Case "View By Called"
sFilter = "Called = TRUE"
Case "Requested Call Back"
sFilter = "RequestedCallBack = TRUE"
Case "Help Needed"
sFilter = "HelpNeeded = TRUE"
End Select
Me.Filter = sFilter
Me.FilterOn = (Len(sFilter) > 0)
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV:

What is happening is the form appears to be going threw the motions of trying to filter but it don't. The code is doing the same thing
 
Hey PHV

Something else strange happened when I trid to get a date field to update when clicking a check box and it will not update the field so this is leading me to believe there is a problem with access form that it on but I am not sure. Any thoughts?

Private Sub Called_Click()
Me.Date = Date
End Sub
 
Have you tried refreshing or requerying the form after you fill in the filter and filteron properties?
 
Date is a reserved word in VBA being the name of a function that returns the system date.

Date is a reserved word in SQL and I think it may be reserved in Access itself.

So if you have a field on a form called Date or a field in a table called date you are really asking for trouble. Your reference to Me.Date seems to imply that this is the case.

Although there are work arounds (PHV put Date in square brackets in his code) the sensible answer is to have field names that are not reserved words. Try Startdate, LeaveDate, ChangeDate, etc as appropriate.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top