Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21238

Search according to textbox serial no enter with adodc from database ms access 2003

$
0
0
Dear Sir,

I have tried to search using adodc from textbox with entered serial Number on it but it does not show me the correct data match with that serial number row from database to display data on the other textbox . Also when i clear the textbox using cancel button it clear textbox but when i enter again then it skip the search area instead it proceed with next condition line. Kindly see what is the problem i'm facing. Here is my code below :-

Code:


Private Sub Form_Activate()

With Adodc1
      .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\GASAGENCYdb.mdb"
      .RecordSource = "SELECT * FROM  CustomerDetails "
      .Refresh
End With

End Sub

Private Sub cmdCancel_Click()

txtSerialNo.Text = ""
txtName.Text = ""
txtSurname.Text = ""
txtSex.Text = ""
txtAddress.Text = ""
txtCity.Text = ""
txtZipCode.Text = ""
txtContactNo.Text = ""
txtOccupation.Text = ""
txtFamilyMembers.Text = ""
txtAppliedOn.Text = ""
txtNoCylinder.Text = ""
txtTypeConnection.Text = ""

End Sub

Private Sub cmdSearch_Click()

txtSerialNo.Enabled = True
txtName.Enabled = True
txtSurname.Enabled = True
txtSex.Enabled = True
txtAddress.Enabled = True
txtCity.Enabled = True
txtZipCode.Enabled = True
txtContactNo.Enabled = True
txtOccupation.Enabled = True
txtFamilyMembers.Enabled = True
txtAppliedOn.Enabled = True
txtNoCylinder.Enabled = True
txtTypeConnection.Enabled = True

Dim search As String

If txtSerialNo.Text = "" Then
    MsgBox " Please enter ID to search "
    Exit Sub
   
  Else
        search = "Select * from CustomerDetails Where SerialNo =" & txtSerialNo.Text
       
            If Adodc1.Recordset.BOF = True Or Adodc1.Recordset.EOF = True Then
                    MsgBox " No Record Found "
                    txtSerialNo.Text = ""
                        Exit Sub
                       
                Else
                                   
                txtName.Text = Adodc1.Recordset.Fields(1)
                txtSurname.Text = Adodc1.Recordset.Fields(2)
                txtSex.Text = Adodc1.Recordset.Fields(3)
                txtAddress.Text = Adodc1.Recordset.Fields(4)
                txtCity.Text = Adodc1.Recordset.Fields(5)
                txtZipCode.Text = Adodc1.Recordset.Fields(6)
                txtContactNo.Text = Adodc1.Recordset.Fields(7)
                txtOccupation.Text = Adodc1.Recordset.Fields(8)
                txtFamilyMembers.Text = Adodc1.Recordset.Fields(9)
                txtAppliedOn.Text = Adodc1.Recordset.Fields(10)
                txtNoCylinder.Text = Adodc1.Recordset.Fields(11)
                txtTypeConnection.Text = Adodc1.Recordset.Fields(12)
               
                Adodc1.RecordSource = search
                Adodc1.Refresh
                   
            End If
    End If

End Sub


Viewing all articles
Browse latest Browse all 21238

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>