Not a Member Yet,
Click here to Register
How do you like the new design?






ID: 304
Viewed: 2412
Added: Aug 19, 2002
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

To search a database and have it printed in textbox. Add a data control and name it Data1 and then add 8 text boxes named the default names.

Highlight all by clicking in box
<!---Declaration--->
Option Explicit
Dim strsql

Highlight All
<!---Code--->
Private Sub cmdclear_Click()
Text4.Text = ""
End Sub

Private Sub cmdsearh_Click()
'get value to search for
strsqlsearch = Text4.Text
'add the value to sql qtery
strsql = "select * from table where field like '*" & strsqlsearch & "*'"
'this just shows the sql for debugging
Text5.Text = strsql
'assign the new QueryDef to data1
Data1.RecordSource = strsql


Data1.Refresh
Data1.Recordset.MoveLast
'count the new query
Text6.Text = Data1.Recordset.RecordCount
Data1.Recordset.MoveFirst
'bind the text boxes
Call filltext
Call populate



End Sub

Private Sub Data1_Reposition()
Call populate

End Sub

Private Sub Form_Load()
'start up sql
strsql = "select * from table"
' fined database on anybodys machine
Dim DBPath As String
DBPath = App.Path

If Right(DBPath, 1) <> "" Then DBPath = DBPath & ""
Data1.DatabaseName = DBPath & "database.mdb"
Data1.RecordSource = strsql
Data1.Refresh
On Error Resume Next

Data1.Recordset.MoveLast
'count the records
Text6.Text = Data1.Recordset.RecordCount
Data1.Recordset.MoveFirst

Call populate
Call filltext

End Sub


Private Sub populate()
'this binds the text boxes manually
If Data1.Recordset.EOF Then
Exit Sub
Else
Text1.Text = Data1.Recordset!Id
Text2.Text = Data1.Recordset!game
Text3.Text = Data1.Recordset!Volume

End If
End Sub

Private Sub filltext()
' fills 2 text boxes
Data1.Recordset.MoveLast
Data1.Recordset.MoveFirst
Text7.Text = ""
Text8.Text = ""
For a = 1 To Data1.Recordset.RecordCount
' this one sets a carriage return
Text7.Text = Text7.Text & Data1.Recordset!field & vbCrLf
' this one is a continous one line
Text8.Text = Text8.Text & Data1.Recordset!field & ", "
Data1.Recordset.MoveNext
Next a

End Sub;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions