rupes_mahal
Registered User.
- Local time
- Today, 11:25
- Joined
- Aug 12, 2001
- Messages
- 60
Hi..
I am trying to set up a search form. I am looking at an example called "Books.mdb". It has an search example in it. I am understanding parts the search operation and how to go about building my own one. But i need help with some of the code.
Below is part of the code for the Search button.
Private Sub cmdSearch_Click()
' Search - build a new filter string
gstrWhereCust = ""
If Not IsNothing(Me!LastName) Then
gstrWhereCust = "[LastName] Like " & Chr$(34) & Me!LastName
If Right$(Me!LastName, 1) = "*" Then
gstrWhereCust = gstrWhereCust & Chr$(34)
Else
gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
End If
End If
If Not IsNothing(Me!FirstName) Then
If IsNothing(gstrWhereCust) Then
gstrWhereCust = "[FirstName] Like " & Chr$(34) & Me!FirstName
Else
gstrWhereCust = gstrWhereCust & " AND [FirstName] Like " & Chr$(34) & Me!FirstName
End If
If Right$(Me!FirstName, 1) = "*" Then
gstrWhereCust = gstrWhereCust & Chr$(34)
Else
gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
End If
End If
If Not IsNothing(Me!City) Then
If IsNothing(gstrWhereCust) Then
gstrWhereCust = "[City] Like " & Chr$(34) & Me!City
Else
gstrWhereCust = gstrWhereCust & " AND [City] Like " & Chr$(34) & Me!City
End If
If Right$(Me!City, 1) = "*" Then
gstrWhereCust = gstrWhereCust & Chr$(34)
Else
gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
End If
End If
I see this code has sections, with the End If procedures. Can anyone please explain to me what this code is doing...
e.g section
If Not IsNothing(Me!City) Then
If IsNothing(gstrWhereCust) Then
gstrWhereCust = "[City] Like " & Chr$(34) & Me!City
Else
gstrWhereCust = gstrWhereCust & " AND [City] Like " & Chr$(34) & Me!City
End If
If Right$(Me!City, 1) = "*" Then
gstrWhereCust = gstrWhereCust & Chr$(34)
Else
gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
End If
End If
PLEASE HELP....
Thank you in advance
Ruby
I am trying to set up a search form. I am looking at an example called "Books.mdb". It has an search example in it. I am understanding parts the search operation and how to go about building my own one. But i need help with some of the code.
Below is part of the code for the Search button.
Private Sub cmdSearch_Click()
' Search - build a new filter string
gstrWhereCust = ""
If Not IsNothing(Me!LastName) Then
gstrWhereCust = "[LastName] Like " & Chr$(34) & Me!LastName
If Right$(Me!LastName, 1) = "*" Then
gstrWhereCust = gstrWhereCust & Chr$(34)
Else
gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
End If
End If
If Not IsNothing(Me!FirstName) Then
If IsNothing(gstrWhereCust) Then
gstrWhereCust = "[FirstName] Like " & Chr$(34) & Me!FirstName
Else
gstrWhereCust = gstrWhereCust & " AND [FirstName] Like " & Chr$(34) & Me!FirstName
End If
If Right$(Me!FirstName, 1) = "*" Then
gstrWhereCust = gstrWhereCust & Chr$(34)
Else
gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
End If
End If
If Not IsNothing(Me!City) Then
If IsNothing(gstrWhereCust) Then
gstrWhereCust = "[City] Like " & Chr$(34) & Me!City
Else
gstrWhereCust = gstrWhereCust & " AND [City] Like " & Chr$(34) & Me!City
End If
If Right$(Me!City, 1) = "*" Then
gstrWhereCust = gstrWhereCust & Chr$(34)
Else
gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
End If
End If
I see this code has sections, with the End If procedures. Can anyone please explain to me what this code is doing...
e.g section
If Not IsNothing(Me!City) Then
If IsNothing(gstrWhereCust) Then
gstrWhereCust = "[City] Like " & Chr$(34) & Me!City
Else
gstrWhereCust = gstrWhereCust & " AND [City] Like " & Chr$(34) & Me!City
End If
If Right$(Me!City, 1) = "*" Then
gstrWhereCust = gstrWhereCust & Chr$(34)
Else
gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
End If
End If
PLEASE HELP....
Thank you in advance
Ruby