Hi, I need to validate a text input with the rest of the data inside excel file. The following is my code.
It just read the text input and only execute data in row 1 only instead of searching other model's data. Any suggestion where did the code goes wrong?
Your help is much appreciated. Thank you.
Private Sub cmdGo_Click()
Dim Model As String
Dim D1 As String
Dim D2 As String
Dim D3 As String
Dim D4 As String
Dim D5 As String
Dim D6 As String
Dim D7 As String
Dim D8 As String
Dim D9 As String
Dim D10 As String
BMV700.Data1.Refresh
Model = txtModel_a.Text
Model = txtModel_b.Text
D1 = txt1(0).Text
D1 = txt2(0).Text
D2 = txt1(1).Text
D2 = txt2(1).Text
D3 = txt1(2).Text
D3 = txt2(2).Text
D4 = txt1(3).Text
D4 = txt2(3).Text
D5 = txt1(4).Text
D5 = txt2(4).Text
D6 = txt1(5).Text
D6 = txt2(5).Text
D7 = txt1(6).Text
D7 = txt2(6).Text
D8 = txt1(7).Text
D8 = txt2(7).Text
D9 = txt1(8).Text
D9 = txt2(8).Text
D10 = txt1(9).Text
D10 = txt2(9).Text
Do Until BMV700.Data1.Recordset.EOF
If BMV700.Data1.Recordset.Fields("Model").Value = Model Then
txtModel_b.Text = BMV700.Data1.Recordset.Fields("Model")
txt1(0).Text = BMV700.Data1.Recordset.Fields("D1")
txt2(0).Text = BMV700.Data1.Recordset.Fields("D1")
txt1(1).Text = BMV700.Data1.Recordset.Fields("D2")
txt2(1).Text = BMV700.Data1.Recordset.Fields("D2")
txt1(2).Text = BMV700.Data1.Recordset.Fields("D3")
txt2(2).Text = BMV700.Data1.Recordset.Fields("D3")
txt1(3).Text = BMV700.Data1.Recordset.Fields("D4")
txt2(3).Text = BMV700.Data1.Recordset.Fields("D4")
txt1(4).Text = BMV700.Data1.Recordset.Fields("D5")
txt2(4).Text = BMV700.Data1.Recordset.Fields("D5")
txt1(5).Text = BMV700.Data1.Recordset.Fields("D6")
txt2(5).Text = BMV700.Data1.Recordset.Fields("D6")
txt1(6).Text = BMV700.Data1.Recordset.Fields("D7")
txt2(6).Text = BMV700.Data1.Recordset.Fields("D7")
txt1(7).Text = BMV700.Data1.Recordset.Fields("D8")
txt2(7).Text = BMV700.Data1.Recordset.Fields("D8")
txt1(8).Text = BMV700.Data1.Recordset.Fields("D9")
txt2(8).Text = BMV700.Data1.Recordset.Fields("D9")
txt1(9).Text = BMV700.Data1.Recordset.Fields("D10")
txt2(9).Text = BMV700.Data1.Recordset.Fields("D10")
Exit Do
Else
BMV700.Data1.Recordset.MoveNext
End If
Loop
Msg = MsgBox("Invalid model, try again!", vbOKOnly + vbExclamation)
If (Msg = 1) Then
BMV700.Show
txtModel_a.Text = ""
txtModel_b.Text = ""
For i = 0 To 9
txt1(i).Text = ""
txt2(i).Text = ""
Next
End If
End Sub