3

以下代码在手机记录表中找到匹配项后在表单上填充值,在条件中,如何在 2 个不同字段中搜索值?我可以用文本框替换组合框,并希望在 2 个字段中搜索,IMEI 和 Mob_number。

Private Sub Combo0_AfterUpdate()

Dim D As Database
Dim rsmob As Recordset
Dim Criteria As String

Set D = CurrentDb
Set rsmob = D.OpenRecordset("Mobile_Phones", DB_OPEN_DYNASET)

Criteria = "[MOB_NUMBER]='" & [Combo0] & "'"

rsmob.FindFirst Criteria

Me!Location = rsmob("User_Name")
Me!MODEL = rsmob("Model")
Me!IMEI = rsmob("IMEI")
Me!DIR = rsmob("DIR")
Me!Status = rsmob("Status")
Me!Account = rsmob("ACCOUNT")
Me!Plan = rsmob("Plan")
Me!MobOrWifi = rsmob("Mob_Or_Wifi")

rsmob.Close

End Sub
4

1 回答 1

3

如何在 2 个不同的字段中搜索值?[IMEI 和 Mob_number]

您应该能够通过将语句更改为来搜索两个字段

Criteria = "[MOB_NUMBER]='" & [Combo0] & "' OR [IMEI]='" & [Combo0] & "'"
于 2013-09-12T01:31:41.193 回答