megatronixs
Registered User.
- Local time
- Today, 19:13
- Joined
- Aug 17, 2012
- Messages
- 719
Hi all,
I have the below code that I use in a form to do a search on more than one field. I need to find one account nr that could be in various fields (up to 10 fields)
How can the below be adjust to look in account_no1 up to account_no10 ?
Greetings.
I have the below code that I use in a form to do a search on more than one field. I need to find one account nr that could be in various fields (up to 10 fields)
How can the below be adjust to look in account_no1 up to account_no10 ?
Code:
Private Sub btn_search_Click()
Dim sSQL As String
On Error GoTo errr
sSQL = "SELECT * FROM qry_search_accounts_2 " & BuildFilter & " ORDER BY qry_search_accounts_2.ccr_code"
Me.frm_search_accounts_2_sub.Form.RecordSource = sSQL
Me.frm_search_accounts_2_sub.Form.RecordSource = Me.frm_search_accounts_2_sub.Form.RecordSource
Exit Sub
errr:
MsgBox Err.Description
End Sub
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim Itm As Variant
Dim Criteria As String
Dim CriteriaPrority As String
Dim CriteriaStatus As String
Dim tmp As String
Dim ShortDate As String
tmp = """"
star = "*"
datos = "#"
'Const conJetDate = "\#mm\/dd\/yy\#"
'ShortDate = "#dd/mm/yy#"
varWhere = Null
Criteria = ""
CriteriaPrority = ""
If Me.search_crr_code_text <> "" Then
varWhere = varWhere & "([account_no1]) OR ([account_no2]) OR ([account_no3]) like " & tmp & Me.search_crr_code_text & tmp & " AND "
End If
If IsNull(varWhere) Then
varWhere = ""
Else
varWhere = "WHERE " & varWhere
If Right(varWhere, 5) = " AND " Then
varWhere = Left(varWhere, Len(varWhere) - 5)
ElseIf Right(varWhere, 4) = " Or " Then
varWhere = Left(varWhere, Len(varWhere) - 4)
End If
End If
BuildFilter = varWhere
End Function
Greetings.