私はvbアクセスコードを使用してselect whereクエリを使用しています。レコードが一致するかどうかを確認するのに問題はありません.sTextboxがデータベースの値と一致しないかどうかに問題があります...「レコードが一致しません"一度だけですが、このステートメントでは、データベース内のレコードがすべて比較されるまで、MsgBox("No Record Match") が何度も出力されます...ステートメントを 1 回しか実行しないため、Exit Do を追加できませんsTextbox をデータベースのすべての値と比較するわけではありません... SQL クエリ ステートメント以外の手段を使用することはできません。本当にありがとうございました。
Dim MyDB As DAO.Database, MyRec As DAO.Recordset, MyList As String
Dim fQue As String, lQue As String, tQue As String
Set MyDB = CurrentDb
If IsNull(sTextbox) Or sTextbox = "" Then
MsgBox ("You must enter Value in Search Box")
End If
If (sTextbox <> "") Or (sTextbox <> "") Then
MsgBox ("There is value")
Set MyDB = CurrentDb
Set MyRec = MyDB.OpenRecordset("SELECT * From clientInfo")
Do While Not MyRec.EOF 'Loop to check if sTextbox = tQue
fQue = MyRec![FirstName]
lQue = MyRec![LastName]
tQue = MyRec![towerUnit]
MyRec.MoveNext
If (sTextbox = tQue) Then
Set MyDB = CurrentDb
Set MyRec = MyDB.OpenRecordset("SELECT * From clientInfo where TowerUnit='" & sTextbox & "'")
FullName = lQue & ", " & fQue
MsgBox (FullName)
ClientTextbox.Value = lQue & ", " & fQue
UnitTextbox.Value = tQue
Exit Do
End If
If (sTextbox <> tQue) Then
MsgBox ("No Record Found")
''Problem lies here because it prints out MsgBox until the While loop is false...
End If
Loop
終了条件