filter and refresh form???

vivou

Registered User.
Local time
Today, 16:19
Joined
Dec 15, 2002
Messages
16
I’m trying to filter a bound form according to some fields but without success… I am doing exactly what I always did ( I already did something exactly in the same way and this works!!!) but this time, in 2 forms this doesn’t work… I don’t understand why!



Can you look:

in form 2 à Private Sub Fram_AfterUpdate()

Here has to be for each alphabet letter a sql filter and refresh at the end the form with only the people whith a name beginning with the selected letter.(people here is a sub form )

Select Case Fram
Case 1
stLinkCriteria = "People.Name Like 'A*'"
Case 2
stLinkCriteria = "People.Name Like 'B*'"
Case 3
stLinkCriteria = "People.Name Like 'C*'"
Case 4
stLinkCriteria = "People.Name Like 'D*'"
Case 5
stLinkCriteria = "People.Name LIKE 'S*'"
End Select

Me.PEOPLE.Form.Filter = stLinkCriteria
' Me.PEOPLE.Form.FilterOn = True
Me.PEOPLE.Form.Refresh





In searchParams form à Private Sub enter_Click()

Here filter on the form according to the selected field ( different form)


Dim stDocName As String
Dim stLinkCriteria As String

Select Case m_stateFilter
Case 1
stLinkCriteria = "Contact.ContactType= '" & contactCB.Column(0) & "'"
Case 3
stLinkCriteria = "Contact.idPeople = '" & nameCB.Column(0) & "'"
Case 4
stLinkCriteria = "Contact.datee BETWEEN #" & date1 & "# AND #" & date2 & "#"


End Select

'open this form with the data from the framFilter
'''''''''''''''''''''''''''''''''''''''''''''''

stDocName = "Contact"
DoCmd.OpenForm stDocName
Forms(stDocName).Filter = stLinkCriteria
Forms(stDocName).Refresh

can someone look and try to help me plzzzzzzzzz????

:confused: :(
 

Attachments

Not got an answer as opening forms with criteria is not something I typically find myself doing but I thought I could offer this to reduce the size of your SELECT CASE statement for Case = 1 through 26 to a few lines by using a loop.

Code:
Dim intCounter As Integer 
For intCounter = 1 To 26 Step 1
   If fram = intCounter Then '
      stLinkCriteria = "People.Name Like '" & Chr(64 + intCounter) & "*'"
   End If
Next intCounter
 
Last edited:
' Me.PEOPLE.Form.FilterOn = True
try removing the apostrophe
Me.PEOPLE.Form.FilterOn = True
 

Users who are viewing this thread

Back
Top Bottom