Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / July 2008

Tip: Looking for answers? Try searching our database.

Filter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AJOLSON - 31 Jul 2008 16:45 GMT
I am using the code below to filter a form from an combo box. However all I
am getting is all records filtered out or null return.  
Lets assume the combo box has a value of "C".  This code is working down to
StrTemp = combo8.text. but when applied in the next line
Docmd.applyfilter,"Field1 = StrTemp" I get a null result when I would expect
a "C" Result.  

Any help would be appreciated  

Here is my code:
Private Sub Command6_Click()
Dim StrTemp As String
Combo8.SetFocus
StrTemp = Combo8.Text
DoCmd.ApplyFilter , "Field1 = StrTemp"

Stop
End Sub
Ryan - 31 Jul 2008 16:50 GMT
Your very close.
StrTemp = Combo8.Text should be StrTemp = Me.Combo8

Signature

Please remember to mark this post as answered if this solves your problem.

> I am using the code below to filter a form from an combo box. However all I
> am getting is all records filtered out or null return.  
[quoted text clipped - 14 lines]
> Stop
> End Sub
AJOLSON - 31 Jul 2008 16:57 GMT
Ryan Thanks,
StrTemp is = to the Content of Combo8 (changed to Me.combo8)
But when it goes to the next line of code
DoCmd.ApplyFilter , "Field1 = StrTemp"
StrTemp = null and seems to loose its value from Me.Combo8  
I even change the code to read this
DoCmd.ApplyFilter , "Field1 = Me.Combo8" but still get no records returned.

> Your very close.
> StrTemp = Combo8.Text should be StrTemp = Me.Combo8
[quoted text clipped - 17 lines]
> > Stop
> > End Sub
AJOLSON - 31 Jul 2008 17:12 GMT
Ok after a little trouble shooting what I can see is that in this code
DoCmd.ApplyFilter , "Field1 = StrTemp"
the StrTemp keeps its value of the combo box Does not pass it to Field1 to
filter on.
Field one in that code remains Null.  
That seems to be the issue.

> Ryan Thanks,
> StrTemp is = to the Content of Combo8 (changed to Me.combo8)
[quoted text clipped - 25 lines]
> > > Stop
> > > End Sub
Golfinray - 31 Jul 2008 17:12 GMT
Try using the standard old filter:
Me.filter = "[your field name] = """ & me.combo8 & """"
Me.filteron = true

> Ryan Thanks,
> StrTemp is = to the Content of Combo8 (changed to Me.combo8)
[quoted text clipped - 25 lines]
> > > Stop
> > > End Sub
AJOLSON - 31 Jul 2008 17:17 GMT
Hurray Success!!!  Thanks Golfinray!!!

Ok one last thing I can’t find any code for a command button that would
clear the filter.  Does anyone know of one and if so please pass it on.  

Again thanks all
Andy

> Try using the standard old filter:
> Me.filter = "[your field name] = """ & me.combo8 & """"
[quoted text clipped - 29 lines]
> > > > Stop
> > > > End Sub
Ryan - 31 Jul 2008 17:19 GMT
Try this
Private Sub Command6_Click()
Dim StrTemp As String
DoCmd.ApplyFilter , "Field1 = " & StrTemp
.FilterOn = True
End Sub
Signature

Please remember to mark this post as answered if this solves your problem.

> Ryan Thanks,
> StrTemp is = to the Content of Combo8 (changed to Me.combo8)
[quoted text clipped - 25 lines]
> > > Stop
> > > End Sub
AJOLSON - 31 Jul 2008 17:31 GMT
Thanks working perfect now.

Andy

> I am using the code below to filter a form from an combo box. However all I
> am getting is all records filtered out or null return.  
[quoted text clipped - 14 lines]
> Stop
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.