Hello! I have been reading articles all day and still do not get an explanation WHY is this happening. I'm using ADO in msaccess and set up a connection with ADODB, which I have successfully achieved, but now I want to use the "Movefirst " and "MoveNext" method of the recordset using an unbound text, so I wrote a simple function code in VB. Now my dilema starts here. I think I got it right at first, but when I run the database, I got nothing for an output, I mean nothing shows up in my text field when the NEXT command button is clicked. I placed my code here, so pls. anyone with a good heart to help me.
Thanks!
Thanks!
Code:
Public Sub recordMoveFirst()
Dim conn As ADODB.Connection
Dim sql As String
sql = "SELECT * FROM tblIW49;"
Set conn = New ADODB.Connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open "C:\MyDocuments\dataPMC.mdb"
conn.Execute sql
'declare a recordset
Dim myTableRS As ADODB.Recordset
Set myTableRS = New ADODB.Recordset
myTableRS.Open "tblIW49", conn, adOpenDynamic, adCmdTable, adLockPessimistic
'go to start of record
'If myTableRS.EOF Then
myTableRS.MoveFirst
Me.txtWorkorder = myTableRS!Workorder
Me.txtActivity = myTableRS!ActivityType
Me.txtCompliant = myTableRS!Compliant
Me.txtComments = myTableRS!Comments
' End If
'close the recordset
myTableRS.Close
Set myTableRS.ActiveConnection = Nothing
'and the connection
conn.Close
Set conn = Nothing
End Sub
Comment