VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A Distinct Search

by Anil Iyengar (4 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (19 Votes)

This a Search program that searches for a
'specific record in a database.
This is a kind of DISTINCT search.
Where u just have to enter the first letter of the data u want and it gives u an output in the grid.

Inputs
'Im using a MSHFlexGrid with a ADO DataControl. 'Connect the ADODC to the Biblio.mdb 'Set Recordsource to Publisers .
Assumes
im using the Mid function. Get ADODC and connect to Biblio.mdb.
Code Returns
A Specific Row of data.

Rate A Distinct Search

Private Sub Command1_Click()
Unload Me 'Unload the program
End
End Sub
Private Sub Form_Load()
'set the Colwidth of the grid
fg.ColWidth(0) = 550
fg.ColWidth(1) = 3000
fg.ColWidth(2) = 3000
End Sub
Private Sub Text1_Change()
Adodc1.RecordSource = "select PubID,Name,[Company Name] from publishers where ucase(mid(pubid,1," & Len(Text1.Text) & "))= '" & Text1.Text & "' and ucase(mid(name,1," & Len(Text2.Text) & "))= '" & Text2.Text & "'"
Adodc1.Refresh
fg.SelectionMode = flexSelectionByRow
'The mid function checkes the records according
'to the info typed in the textbox.
'It queries the ADODC with every letter typed
'in the textbox,making it a bit more refined
'search on the records.
End Sub
Private Sub Text2_Change()
Adodc1.RecordSource = "select PubID,Name,[Company Name] from publishers where ucase(mid(name,1," & Len(Text2.Text) & "))= '" & Text2.Text & "'"
Adodc1.Refresh
fg.SelectionMode = flexSelectionByRow
End Sub
'Just use the mid function as i have and
'you can query any database for the record.
'This kind of search is useful if the u have to
'go thru a large database.

'PLEASE VOTE

Download this snippet    Add to My Saved Code

A Distinct Search Comments

No comments have been posted about A Distinct Search. Why not be the first to post a comment about A Distinct Search.

Post your comment

Subject:
Message:
0/1000 characters