|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
method of going back to the front records?
Hello!
I am using visual basic 6 and MSAccess 2000... I am askin about whether there is a method or functions that allow the recordsetpointer to point to the first field of the recordset...? Thanks for reading my message. Ham |
|
#2
|
||||
|
||||
|
how about showing some code as to how you are interacting with the recordset...
if you are using an adodb recordset you can use the movefirst method. |
|
#3
|
|||
|
|||
|
|
|
#4
|
|||
|
|||
|
U can do:
dim rs as recordset rs.movefirst .... |
|
#5
|
|||
|
|||
|
My Code goes like tt:
Code:
Option Explicit
Dim n, m, i, inc, t1Inc, t2Inc As Integer
Dim WithEvents cnn As ADODB.Connection
Dim WithEvents rst As ADODB.Recordset
Private Sub Form_Load()
Dim cnnstr As String
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
cnnstr = "Select * from Node"
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=C:\My Documents\My Project\bearer.mdb"
.Open
End With
With rst
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open cnnstr, cnn
End With
End Sub
Private Sub cmdFind_Click() 'Find Button
Dim sFind As String
Dim f As ADODB.Field
Dim counter, posRec As Integer
inc = -500
t1Inc = -500
t2Inc = -500
If txtBID.Text = "" Then
MsgBox "Please Enter the correct bearer Id", vbInformation, "Error"
txtBID.SetFocus
Exit Sub
End If
sFind = Trim(txtBID.Text)
rst.Find "Bearer_ID LIKE " & "'" & sFind & "*'"
posRec = rst.AbsolutePosition
If (posRec > adPosBOF) Then
If (Not posRec = rst.BOF Or rst.EOF) Then
'if the fields are not null
For Each f In rst.Fields
If IsNull(f.Value) Then '<!-- how can set the number of fields to come out
Call LoadImg
Call LoadText1
Call LoadText2
End If
Next
'If picturebox is too small, increase the width and make scrollbar visible
If imgbox(imgbox.UBound).Left > picInner.ScaleWidth Then
picInner.Width = imgbox(imgbox.UBound).Left + 2000
HBar.Visible = True
End If
End If
Else
MsgBox "No records Found", vbCritical, "No records"
End If
rst.MoveFirst
loadRecord ' to load the records into textboxes
End Sub
Public Sub loadRecord()
Text1(1).Text = rst.Fields("Node1").Value
Text2(1).Text = rst.Fields("Node2").Value
Text1(2).Text = rst.Fields("Node3").Value
Text2(2).Text = rst.Fields("Node4").Value
Text1(3).Text = rst.Fields("Node5").Value
End Sub
Private Sub LoadImg()
Load imgbox(imgbox.UBound + 1) 'Load imgbox() array
inc = inc + 2000
With imgbox(imgbox.UBound) ' imgbox property
.Picture = LoadPicture(App.Path & "\circle.gif")
.Left = inc
.Top = 2000
.Width = 700
.Height = 700
.Visible = True
End With
End Sub
Private Sub LoadText1()
Load Text1(Text1.UBound + 1) 'load upper textboxes
t1Inc = t1Inc + 2000
With Text1(Text1.UBound) 'Textboxes properties
.Left = t1Inc
.Top = 650
.Width = 800
.Height = 500
.Visible = True
End With
End Sub
Private Sub LoadText2()
Load Text2(Text2.UBound + 1) 'load lower textboxes
t2Inc = t2Inc + 2000
With Text2(Text2.UBound) 'Textboxes properties
.Left = t2Inc
.Top = 3200
.Width = 800
.Height = 500
.Visible = True
End With
End Sub
*edit* placed code tags around content Last edited by Onslaught : September 25th, 2003 at 08:21 AM. |
|
#6
|
||||
|
||||
|
Ok, I'm not really sure what your asking.
By re-reading your first post, I believe I have misunderstood what you are wanting as as recordset pointer points to a row and not to a field. Can you please explain what you want to accomplish. |
|
#7
|
|||
|
|||
|
Thanks Onslaught for reading my reply.
I wan the recordset pointer to point to the fields in a row instead of row by row... So tt i can set where the pointer of which fields i wan to start retrieving data from? Thanks. |
|
#8
|
||||
|
||||
|
Sorry, don't really know of such a method of function to accomplish this. It would have to be something custom.
|
|
#9
|
|||
|
|||
|
Thanks Onslaught...
Thanks for replying to my post... I really appreciated ur help. Thanks... if i happen to find out how to do, i will msg U to tell U how it is done... Thanks... |
|
#10
|
|||
|
|||
|
I don't know too..
|
|
#11
|
||||
|
||||
|
just as an idea, you could use a counter to keep track of where you are in the fields and if you haven't gotten to the field you wish to start with then continue in the loop.
i.e. Code:
Private Sub foo(rs as ADODB.Recordset, st as Integer)
Dim cntr as Integer
cntr = 0
For Each f in rs.Fields
cntr = cntr + 1
If (cntr < st) Then Next
'do what you wanted with the field
Next
End Sub
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > method of going back to the front records? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|