But I have a new problem. Prior to this present capacity to populate two Access tables, I could extract from one table (same mdb file) and fill textboxes on the form, and now I can't. I have the following code:
Code:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim intIdx As Integer
Dim strCust As String
Dim blnFnd As Boolean = False
Me.txtTelephone.Text = Me.txtTelephone.Text.Replace("(", "")
Me.txtTelephone.Text = Me.txtTelephone.Text.Replace(")", "")
Me.txtTelephone.Text = Me.txtTelephone.Text.Replace("-", "")
'***** Prompt for phone number
' strCust = InputBox("Customer Number:", "Find by Customer Number", "")
strCust = txtTelephone.Text
'***** Search for the Customer number
For intIdx = 0 To (DatCust.Rows.Count - 1)
If strCust = CStr(DatCust.Rows(intIdx)("fldTelephone")) Then
txtTelephone.Text = (CStr(DatCust.Rows(intIdx)("fldTelephone")))
txtName.Text = (CStr(DatCust.Rows(intIdx)("fldName")))
txtAddress1.Text = (CStr(DatCust.Rows(intIdx)("fldAddr1")))
'txtAddress2.Text = (CStr(DatCust.Rows(intIdx)("fldAddr2")))
txtCity.Text = (CStr(DatCust.Rows(intIdx)("fldCity")))
txtState.Text = (CStr(DatCust.Rows(intIdx)("fldState")))
txtZipCode.Text = (CStr(DatCust.Rows(intIdx)("fldZip")))
Me.txtTelephone.Text = Me.txtTelephone.Text.Insert(0, "(")
Me.txtTelephone.Text = Me.txtTelephone.Text.Insert(4, ")")
Me.txtTelephone.Text = Me.txtTelephone.Text.Insert(8, "-")
Me.txtZipCode.Text = Me.txtZipCode.Text.Insert(5, "-")
blnFnd = True
End If
Next
If Not blnFnd Then
MsgBox("Customer not found")
txtTelephone.Focus()
txtTelephone.SelectAll()
End If
End Sub
If I type a telephone number (as customer ID) in txtTelephone, it gives the "Customer not found" message, and I know it's there. Anything obvious that's wrong or is there a better approach, one that works? I don't want to be repetitive, but I've been looking through Wrox books all evening and can't find an answer.
Thanks,
Hollertrek