I would like to see if there is a command to show the whole record(row) at once. By now I only find method to show individual columns. I am using a ADO connection to the ms access's mdb. Thanks. By the way, I don't know how can I print a message in MS Access's VB form.......does vb provide a console to show that? Debug.Print don't give me anything, I only success with MsgBox...
With cmdCommand
.ActiveConnection = conConnection
.CommandText = "SELECT * from tableA"
.CommandType = adCmdText
End With
With rstRecordSet
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockReadOnly
.Open cmdCommand
End With
If rstRecordSet.EOF = False Then
rstRecordSet.MoveFirst
Do
MsgBox rstRecordSet.Fields(0) & " " & rstRecordSet.Fields(1)
rstRecordSet.MoveNext
Loop Until rstRecordSet.EOF = True
End If
Recordset objects can support two types of updating: immediate and batched. In immediate updating, all changes to data are written immediately to the underlying data source once you call the Update method.
The default cursor for an ADO Recordset is a forward-only, read-only cursor located on the server. Using the Open method on a Recordset object opens a cursor that represents records from a base table, the results of a query, or a previously saved Recordset.
Static cursor - Provides a static copy of a recordset for you to use to find data or generate reports. Additions, changes, or deletions by other users will not be visible. This is the only type of cursor allowed when you open a client-side Recordset object.
First off, Debug.Print
prints to the Immediate Window in the VB[A] Editor. If it's not showing, press Ctrl-G.
Second, there is no single command to show the whole record, you'll have to assemble it the way that Xavinou does in his (her?) answer. Here's the VB syntax, ignoring recordset creation & EOF check (Note that I've declared the variables--you are using Option Explicit, yes?):
Dim fld As Field
Dim msg As String
For Each fld In rstRecordSet.Fields
msg = msg & fld.Value & "|"
Next
Debug.Print msg 'or MsgBox msg
I think the pipe ("|") makes a better separator than a space, since it's less likely to occur in your data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With