con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" & vardatabaseloc
con.open()
If Not Trim(txtref.Text) = "" Then
lbltotalresults.Text = "Search Results for: " & " " & Trim(txtref.Text) & " "
sql = "SELECT * FROM " & table & " WHERE [Ref] LIKE %" & Trim(txtref.Text) & "%"
End If
If Not Trim(txtfirstname.Text) = "" Then
If sql = Nothing Then
lbltotalresults.Text = "Search Results for: " & Trim(txtfirstname.Text) & " "
sql = "SELECT * FROM " & table & " WHERE [FirstName] LIKE %" & Trim(txtfirstname.Text) & "%"
Else
lbltotalresults.Text = "Search Results for: " & Trim(txtfirstname.Text) & " "
sql = sql & " AND [FirstName] LIKE %" & Trim(txtfirstname.Text) & "%"
End If
End If
If Not Trim(txtsurname.Text) = "" Then
If sql = Nothing Then
lbltotalresults.Text = "Search Results for: " & Trim(txtsurname.Text) & " "
sql = "SELECT * FROM " & table & " WHERE [LastName] LIKE %" & Trim(txtsurname.Text) & "%"
Else
lbltotalresults.Text = lbltotalresults.Text & " " & Trim(txtsurname.Text) & " "
sql = sql & " AND [LastName] LIKE %" & Trim(txtsurname.Text) & "%"
End If
End If
If Not Trim(txtdob1.Text) = "" And Not Trim(txtdob2.Text) = "" And Not Trim(txtdob3.Text) = "" Then
If sql = Nothing Then
lbltotalresults.Text = "Search Results for: " & " " & Trim(txtdob1.Text) & "/" & Trim(txtdob2.Text) & "/" & Trim(txtdob3.Text) & " " _
sql = "SELECT * FROM " & table & " WHERE [DOB] LIKE %" & Trim(txtdob1.Text) & "/" & Trim(txtdob2.Text) & "/" & Trim(txtdob3.Text) & "%"
Else
lbltotalresults.Text = lbltotalresults.Text & " " & Trim(txtdob1.Text) & "/" & Trim(txtdob2.Text) & "/" & Trim(txtdob3.Text) & " " _
sql = sql & " AND [DOB] LIKE %" & Trim(txtdob1.Text) & "/" & Trim(txtdob2.Text) & "/" & Trim(txtdob3.Text) & "%"
End If
End If
If sql = Nothing Then
sql = "SELECT * FROM " & table
End If
\\Data adapter settings and then fills it.
dacand = New OleDb.OleDbDataAdapter(sql, con)
dacand.Fill(dscand, vardatabaseloc)
\\close connection to the database.
con.Close()
\\Goes to the showallcandidates sub.
showallcandidates()
\\The following is the showallcandidates sub
If sql = "SELECT * FROM " & table Then
lblnofound.Text = "Total candidates for " & varcompanyname & ": " & maxrows
lbltotalresults.Text = "Search Results for: All Candidates"
Else
lblnofound.Text = "Number of candidates found: " & maxrows
End If
\\Counts how many rows/records have been found.
maxrows = dscand.Tables(vardatabaseloc).Rows.Count
If inc = maxrows - 1 Then
Exit Sub
Else
\\Clear all search lbls first
clearsearchlbl()
End If
If inc <> maxrows - 1 Then
inc = inc + 1
lnkresult1.Text = dscand.Tables(vardatabaseloc).Rows(inc).Item(0) & " / " & dscand.Tables(vardatabaseloc).Rows(inc).Item(1) & " " & dscand.Tables(vardatabaseloc).Rows(inc).Item(2)
Else
Exit Sub
End If
If inc <> maxrows - 1 Then
inc = inc + 1
lnkresult2.Text = dscand.Tables(vardatabaseloc).Rows(inc).Item(0) & " / " & dscand.Tables(vardatabaseloc).Rows(inc).Item(1) & " " & dscand.Tables(vardatabaseloc).Rows(inc).Item(2)
Else
lnkresult2.Text = Nothing
lnkresult3.Text = Nothing
lnkresult4.Text = Nothing
Exit Sub
End If
If inc <> maxrows - 1 Then
inc = inc + 1
lnkresult3.Text = dscand.Tables(vardatabaseloc).Rows(inc).Item(0) & " / " & dscand.Tables(vardatabaseloc).Rows(inc).Item(1) & " " & dscand.Tables(vardatabaseloc).Rows(inc).Item(2)
Else
lnkresult3.Text = Nothing
lnkresult4.Text = Nothing
Exit Sub
End If
If inc <> maxrows - 1 Then
inc = inc + 1
lnkresult4.Text = dscand.Tables(vardatabaseloc).Rows(inc).Item(0) & " / " & dscand.Tables(vardatabaseloc).Rows(inc).Item(1) & " " & dscand.Tables(vardatabaseloc).Rows(inc).Item(2)
Else
lnkresult4.Text = Nothing
Exit Sub
End If