|
-
Oct 17th, 2001, 09:35 AM
#1
Thread Starter
Junior Member
Code to display contents of a table from a database
Hie...
I am looking for a code to perform the following:
1. Created a database with the table IT_COMPANIES having the fields compid, compname, dtestablished etc. The table has 100 records.
2. Created a form IT HISTORY with a button btnmoredetails, on clicking the button, the table IT_COMPANIES should be opened, but displaying the first 10 records. Now in this case the table should have the next and previous buttons to navigate to the next or last 10 records.
Please help me with a code that will perform the tasks in step two.
-
Oct 17th, 2001, 10:58 AM
#2
Frenzied Member
Code:
''Do this in form declarations
Dim cn as New ADODB.Connection
Dim rs as New ADODB.RecordSet
Dim sql as String
''Button click event
Private Sub Command1_Click()
sql = "select * from IT_Companies order by "whatever you want"
cn.Open("your connection string")
rs.CursorType = adOpenDynamic
Set rs = cn.Execute(sql)
Call Next10
End Sub
Sub Next10()
Dim i as Integer
While i < 10 and Not rs.EOF
'put the information wherever you want it
rs.Movenext
i = i + 1
Wend
End Sub
Sub Previous10()
Dim i as Integer
While i < 10 and Not rs.BOF
'put the information wherever you want it
rs.MovePrevious
i = i + 1
Wend
End Sub
Private Sub cmdNext_Click()
Call Next10
End Sub
Private Sub cmdPrevious_Click()
Call Previous10
End Sub
Make sure you reference the MS ADO 2.5 Library
-
Oct 18th, 2001, 01:17 AM
#3
Thread Starter
Junior Member
Your code
Thank you, i'll try your code and will get back to u if i have a problem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|