Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Coding for find or search using DATA Bar


Coding for find or search using DATA Bar

Author
Message
dryan
dryan
Forum God
Forum God (1.8K reputation)Forum God (1.8K reputation)Forum God (1.8K reputation)Forum God (1.8K reputation)Forum God (1.8K reputation)Forum God (1.8K reputation)Forum God (1.8K reputation)Forum God (1.8K reputation)Forum God (1.8K reputation)

Group: Forum Members
Posts: 5, Visits: 8
Hi to everyone. it's me again. Smile sorry for always troubling you guys but the thing is i'm on my last chance to graduate and i have my dental system working and everything is all set but the trouble is i'm having problems with the Find/Search button in which wherein when the user click on the Search/Find(command button) it would open up a new form with One label(label1) named as Enter Patient Number and a text box(text1) and 3 command buttons

SEARCH Patient History

SEARCH Patient Form

EXIT

and since it's a search form i put in two Data Bar, the one wherein you the codings would start as Data1.recordset.addnew etc....

and the reason why it's two Data Bar is because the search form would search a two kinds of patient record, the patient history, which would include the medical records of that certain patient and the patient form which would include the necessary Patient's Information such as Address, Date of birth etc.



the thing is i don't quite get it how to make that search button work. T__T forgive me, i'm pathetic.



i tried to copy down notes from the book VB6 databases by charles williams and all it shows there are how to use the search button using Adodc.

what i did now is tried to replace the necessary Adodc terms with Data1 and i still can't get it right.



in the book it stated about using strings and adding indexes to the labels and text boxes of the form wherein the criteria for searching would work. in my part the criteria for searching would just be patient number so what i did is i put and index number to the Patient number label and the Patient Number text box. i put 0(zero) on both of it.



here's a copy of the coding that i used.



Public Sub FindString()

Dim strFind As String

Dim intFields As Integer





If Trim(txtsearch) <> "" Then

strFind = Trim(Command1)



With Form4.Data1.Recordset

Do Until .EOF



For intFields = 0 To 1



If InStr(1, Form4.txtnumber(intFields), strFind, _

vbTextCompare) > 0 Then

Form4.txtnumber(intFields).SelStart = InStr(1, Form4.txtnumber(intFields), _

strFind, vbTextCompare) - 1

Form4.txtnumber(intFields).SelLength = Len(strFind)

Form4.txtnumber(intfield).SetFocus



Exit Sub

End If



Next

.MoveNext

DoEvents

Loop

MsgBox "Record Not Found"

.MoveFirst

End With

End If

Exit Sub



End Sub

Private Sub Command1_Click()

If Form4.Data1.Recordset.RecordCount > 0 Then

Form4.Data1.Recordset.MoveFirst

Call FindString

Else

MsgBox "Recordset is Empty"

End If





End Sub





Please kindly help me T_____T
bytelogik
bytelogik
Forum God
Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)

Group: Forum Members
Posts: 3, Visits: 5
Hmm..



You can check out a following example as an search.

This assumes a table called patients where you store patient data

This assumes a field called PatientNo where you store patient number / ID



dim PatientNumber as long 'assuming patient number is numerical.

PatientNumber=Val(Trim(txtPatientNumber)) 'get the patient number from a text box named txtPatientNumber

Data1.Recordsource="select * from patients where PatientNo ="& PatientNumber &""

Data1.Refresh

If Data1.Recordset.Recordcount >0 then

'Record found

Else

'Record Not found

End If



Let me know if you have any problems in searching.

Set Data1.Recordset=Nothing


__________________________

From Logics To Life

http://bytelogik.wordpress.com
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search