filter the subform (1 Viewer)

rio

Registered User.
Local time
Tomorrow, 00:40
Joined
Jun 3, 2008
Messages
124
Need some help!!
I create this code to filter the subform.
Code:
Private Sub cmdCari_Click()
Dim stLinkCriteria As String
Dim stLinkCriteria2 As String

stLinkCriteria = "[Year] =" & "'" & Me.Year1 & "'" & " "
stLinkCriteria2 = "[Location] =" & "'" & Me.Location1 & "'" & ""

If stLinkCriteria .Value = "" Then
stLinkCriteria3 = stLinkCriteria2
Else
If stLinkCriteria2 = "" Then
stLinkCriteria3 = stLinkCriteria
Else
stLinkCriteria3 = stLinkCriteria & " And " & stLinkCriteria2
End If
End If
Me.GEPematuhan.Form.Filter = stLinkCriteria3
Me.GEPematuhan.Form.FilterOn = True

End Sub
but it doesn't work.

then how to put this ito that code

Code:
If stLinkCriteria2 = "" AND stLinkCriteria .Value = "" Then
 stLinkCriteria3 =  [COLOR=Red]SHOW ALL RECORD[/COLOR]
 

rio

Registered User.
Local time
Tomorrow, 00:40
Joined
Jun 3, 2008
Messages
124
I try change my code.. it working perfect.
this the code.
Code:
Dim stLinkCriteria As String
Dim stLinkCriteria2 As String

stLinkCriteria = "[Year] =" & "'" & Me.Year1 & "'" & " "
stLinkCriteria2 = "[Location] =" & "'" & Me.Location1 & "'" & ""

If IsNull(Me.Year1) Then
        stLinkCriteria3 = stLinkCriteria2
Else
If IsNull(Me.Location1) Then
        stLinkCriteria3 = stLinkCriteria
Else
stLinkCriteria3 = stLinkCriteria & " And " & stLinkCriteria2
End If
End If

Me.GEPematuhan.Form.Filter = stLinkCriteria3
Me.GEPematuhan.Form.FilterOn = True

If IsNull(Me.Year1) And IsNull(Me.Location1) Then
Me.GEPematuhan.Form.FilterOn = False
End If
End Sub
 

rio

Registered User.
Local time
Tomorrow, 00:40
Joined
Jun 3, 2008
Messages
124
can i used this code to create new table??????
 

boblarson

Smeghead
Local time
Today, 09:40
Joined
Jan 12, 2001
Messages
32,059
can i used this code to create new table??????

Just curious but why do you need a new table? Remember - you can do 99.9% of things with a query where you would normally use a table.
 
  • Like
Reactions: rio

rio

Registered User.
Local time
Tomorrow, 00:40
Joined
Jun 3, 2008
Messages
124
hi bob. thanks for advice.
my query name is GEPematuhan. can i make my query permanently show filtering data. or i should create new query. can you help me with the code.
 

boblarson

Smeghead
Local time
Today, 09:40
Joined
Jan 12, 2001
Messages
32,059
How do you intend to use it? That will kind of determine what path we take.
 

rio

Registered User.
Local time
Tomorrow, 00:40
Joined
Jun 3, 2008
Messages
124
hi bob. Thanks.
I already got it. I used this code on my query.
Code:
Like Nz([Forms]![GEpost]![Location1],"*")
 

Users who are viewing this thread

Top Bottom