Created
October 19, 2011 17:23
-
-
Save gsherman/1299003 to your computer and use it in GitHub Desktop.
705 - address form - filter by x_suite.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Dim DEFAULT_ADDRESS As String | |
Const DEFAULT_ADDRESS_OBJID = 268435457 | |
Sub form_load() | |
Me.DoDefault | |
Dim br As New BulkRetrieve | |
Dim addressList As List | |
Dim recAddress As Record | |
br.SimpleQuery 0, "address" | |
br.AppendFilter 0, "objid", cbEqual, DEFAULT_ADDRESS_OBJID | |
br.RetrieveRecords | |
Set addressList = br.GetRecordList(0) | |
If addressList.Count = 0 Then | |
MsgBox "ERROR; Unable to find default address with objid of " + cstr(DEFAULT_ADDRESS_OBJID) | |
End If | |
Set recAddress = addressList.ItemByIndex(0) | |
DEFAULT_ADDRESS = recAddress.GetField("address") | |
End Sub | |
Function modifyFilterValue(filterValue As String) | |
Dim modifiedFilterValue As String | |
modifiedFilterValue = filterValue | |
Select Case WILDCARD.Selected | |
Case "starts with", "" | |
If Right$(modifiedFilterValue, 1) <> "%" Then | |
modifiedFilterValue = modifiedFilterValue + "%" | |
End If | |
Case "ends with" | |
If Left$(modifiedFilterValue, 1) <> "%" Then | |
modifiedFilterValue = "%" + modifiedFilterValue | |
End If | |
Case "contains" | |
If Right$(modifiedFilterValue, 1) <> "%" Then | |
modifiedFilterValue = modifiedFilterValue + "%" | |
End If | |
If Left$(modifiedFilterValue, 1) <> "%" Then | |
modifiedFilterValue = "%" + modifiedFilterValue | |
End If | |
End Select | |
modifyFilterValue = modifiedFilterValue | |
End Function | |
Sub Select_click() | |
Dim mylist As list | |
Dim mybulk As New bulkretrieve | |
Dim modifiedFilterValue As String | |
Dim filterOperator As Integer | |
Dim filterValue As String | |
If sort.value<>"x_suite" Then | |
Me.Dodefault | |
Exit Sub | |
End If | |
filterValue = FILTER_BY.Value | |
'Init the form by filtering for the default address | |
sort.value = "address" | |
FILTER_BY.Value = DEFAULT_ADDRESS | |
Ctl_SELECT.Value = 1 | |
'Then do the query that we really want to do | |
modifiedFilterValue = modifyFilterValue(filterValue) | |
filterOperator = cbLike | |
If WILDCARD.Selected = "sounds like" Then filterOperator = cbSoundsLike | |
sort.value="x_suite" | |
FILTER_BY.Value = filterValue | |
mybulk.SimpleQuery 0, "address" | |
mybulk.AppendFilter 0, "x_suite", filterOperator, modifiedFilterValue | |
If ASC_DESC.Selected = "Descending" Then mybulk.AppendSort 0, "x_suite", cbDescending | |
mybulk.RetrieveRecords | |
Set mylist = mybulk.GetRecordList(0) | |
cobj_address.fill mylist | |
cobj_TOTAL_NUM.Fill mylist.Count | |
End Sub | |
Sub FIELD_ARRAY_Click() | |
Me.Dodefault | |
End Sub | |
Sub Open_Click() | |
Me.Dodefault | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment