| ' *********************************************************
' 検索実行
' *********************************************************
Private Sub btn検索実行_Click()
Dim strQuery, strCond
strQuery = "select 郵便番号,都道府県,市区町村,町域 "
strQuery = strQuery & " from 郵便番号マスタ"
strQuery = strQuery & " where "
strCond = ""
If Trim(Me.txt郵便番号.Value) <> "" Then
If strCond <> "" Then
strCond = strCond & " and "
End If
strCond = strCond & " 郵便番号 like "
strCond = strCond & "'*" & Me.txt郵便番号.Value & "*'"
End If
If Trim(Me.txt市区町村.Value) <> "" Then
If strCond <> "" Then
strCond = strCond & " and "
End If
strCond = strCond & " 市区町村 like "
strCond = strCond & "'*" & Me.txt市区町村.Value & "*'"
End If
If Trim(Me.txt町域.Value) <> "" Then
If strCond <> "" Then
strCond = strCond & " and "
End If
strCond = strCond & " 町域 like "
strCond = strCond & "'*" & Me.txt町域.Value & "*'"
End If
If strCond = "" Then
MsgBox ("検索条件を指定して下さい")
Else
Me.lst郵便番号.RowSource = strQuery & strCond
End If
End Sub
| |