Go Back   DeveloperBarn Forums > Databases > Microsoft Access

Sponsored Links

Discuss "filters on a form" in the Microsoft Access forum.

Microsoft Access - Microsoft Access is a database for small to medium applications. Learn tips and tricks and best database practices here.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1  
Old July 25th, 2008, 04:40 PM
Barn Newbie
 
Join Date: Jul 2008
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 1
javier_83 is an unknown quantity at this point
Default filters on a form

hi, i make a form, where i can see all the models i have on my database, so i can pick the one i need!!but i want to make a filter
i have several textbox so i can choose, what do i wan to make the filter i use a code, and make the filter but i cant use multiples filter, this make me use only one filter at timei use this code

Quote:
Option Compare Database
Private Sub buscarnombre_AfterUpdate()
DoCmd.ApplyFilter "", "[Nombre] Like '" & Me.buscarnombre & "*'"
End Sub
Private Sub buscarnombre_Change()
On Error GoTo Err_Comando12_Click
DoCmd.ApplyFilter "", "[Nombre] Like '" & Me.buscarnombre & "*"
buscarnombre.SetFocus
buscarnombre.SelStart = Len(buscarnombre)
Exit_Comando12_Click:
Exit Sub
Err_Comando12_Click:
Resume Exit_Comando12_Click
End Sub
Private Sub buscarso_AfterUpdate()
DoCmd.ApplyFilter "", "[SO] Like '" & Me.buscarso & "*'"
End Sub
Private Sub buscarso_Change()
On Error GoTo Err_Comando12_Click
DoCmd.ApplyFilter "", "[SO] Like '" & Me.buscarso & "*"
buscarso.SetFocus
buscarso.SelStart = Len(buscarso)
Exit_Comando12_Click:
Exit Sub
Err_Comando12_Click:
Resume Exit_Comando12_Click
End Sub
Private Sub buscarsp_AfterUpdate()
DoCmd.ApplyFilter "", "[servpack] Like '" & Me.buscarsp & "*'"
End Sub
Private Sub buscarsp_Change()
On Error GoTo Err_Comando12_Click
DoCmd.ApplyFilter "", "[Servpack] Like '" & Me.buscarsp & "*"
buscarsp.SetFocus
buscarsp.SelStart = Len(buscarsp)
Exit_Comando12_Click:
Exit Sub
Err_Comando12_Click:
Resume Exit_Comando12_Click
End Sub
Private Sub Form_Current()
Me.Refresh
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.Refresh
End Sub

what can i do, to amek a multiple filter?????'


thanks, and sorry for my english!!
Reply With Quote
Sponsored Links
  #2  
Old July 28th, 2008, 11:47 AM
AOG123's Avatar
Lightning Master

 
Join Date: Mar 2008
Location: Fortress Of Solitude
Posts: 93
Thanks: 6
Thanked 23 Times in 18 Posts
Rep Power: 1
AOG123 is on a distinguished road

Awards Showcase
Microsoft Access 
Total Awards: 1

Default

take a look at this sample,.

<<http://www.developerbarn.com/microso...t-filters.html>>

This can be applied to Combos aswell,.
__________________
If i helped you, make me famous by clicking the
Reply With Quote
  #3  
Old July 28th, 2008, 12:17 PM
AOG123's Avatar
Lightning Master

 
Join Date: Mar 2008
Location: Fortress Of Solitude
Posts: 93
Thanks: 6
Thanked 23 Times in 18 Posts
Rep Power: 1
AOG123 is on a distinguished road

Awards Showcase
Microsoft Access 
Total Awards: 1

Default

Changed my mind,. what are you using,. form and sub continuous?

we may be able to add somthing like


Code:
Dim strFilter As String

strFilter = ""
If Len(Nz(Me.Combo1)) > 0 Then
    strFilter = " and [Field]='" & Me.SearchCombo1 & "'"
End If
If Len(Nz(me.Combo2)) > 0 Then
    strFilter = " and [Field1]='" & Me.SearchCombo2 & "'"
End If
If Len(Nz(me.Combo3)) > 0 Then
    strFilter = " and [Field2]='" & Me.SearchCombo3 & "'"
End If

DoCmd.ApplyFilter
This should cope with the null values,. but i'll need to test it as applyfilter is generally a bit fussy. So may not work first time around.
Reply With Quote
  #4  
Old July 28th, 2008, 01:02 PM
Barn Newbie
 
Join Date: Jul 2008
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 1
javier_83 is an unknown quantity at this point
Default

Quote:
Originally Posted by AOG123 View Post
take a look at this sample,.

<<http://www.developerbarn.com/microso...t-filters.html>>

This can be applied to Combos aswell,.
IT WORKS PERFECT!!!!

Thank you very much!! i change as text box, and put the me.refresh on the AFterupdate event, and works Perfect!!!!
Reply With Quote
  #5  
Old July 28th, 2008, 01:03 PM
Barn Newbie
 
Join Date: Jul 2008
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 1
javier_83 is an unknown quantity at this point
Default

Quote:
Originally Posted by AOG123 View Post
Changed my mind,. what are you using,. form and sub continuous?

we may be able to add somthing like


Code:
Dim strFilter As String

strFilter = ""
If Len(Nz(Me.Combo1)) > 0 Then
    strFilter = " and [Field]='" & Me.SearchCombo1 & "'"
End If
If Len(Nz(me.Combo2)) > 0 Then
    strFilter = " and [Field1]='" & Me.SearchCombo2 & "'"
End If
If Len(Nz(me.Combo3)) > 0 Then
    strFilter = " and [Field2]='" & Me.SearchCombo3 & "'"
End If

DoCmd.ApplyFilter
This should cope with the null values,. but i'll need to test it as applyfilter is generally a bit fussy. So may not work first time around.
i was using that, but i made it like your exameple and works perfect!!
Reply With Quote
Reply

  DeveloperBarn Forums > Databases > Microsoft Access

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Email] Simple way to email form Rebelle ASP Development 17 August 14th, 2008 04:03 PM
Time Entry Form sbenj69 Microsoft Access 2 July 14th, 2008 02:11 PM
Cascading List Filters AOG123 Microsoft Access 0 May 6th, 2008 11:35 AM
Maintaining Form Data after forms authentication timeout richyrich .Net Development 13 April 17th, 2008 01:28 AM


All times are GMT -4. The time now is 01:49 PM.



Content Relevant URLs by vBSEO 3.2.0