Question

The following code is populating values on a form after it finds a match in a Mobile phone records table, in the criteria, how can I search for the value in 2 different fields? I could replace the combo box with a text box and would like to search in 2 fields, IMEI and 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
Was it helpful?

Solution

how can I search for the value in 2 different fields? [IMEI and Mob_number]

You should be able to search on two fields by changing your statement to

Criteria = "[MOB_NUMBER]='" & [Combo0] & "' OR [IMEI]='" & [Combo0] & "'"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top