Binding ADO recordset to form

M

mw

If anyone could give me some help that would be great! I've been programming for years but I'm new to access and figuring out ADO and DAO is quite confusing ... your help would be much appreciated!!!

I'm having trouble binding an ADO recordset to a form. Should I even be doing this? I've referred to (KB 281998), but here's the problem: I want the recordset to be adOpenDynamic (so the user can use custom buttons to do prev/next/top/bottom/find and view all of the updated records using the form). When I use code (like this below) the locktype is reset to adOpenStatic??

Private Sub Form_Open(Cancel As Integer
Dim strPath As Strin
Dim strSQL As Strin
Dim cn As ADODB.Connectio
Dim Defrst As ADODB.Recordse

On Error GoTo ErrorHandle
Set Defrst = New ADODB.Recordse
strpath = "C:\test\test.mdb
Set cn = New ADODB.Connectio
Set cn = CurrentProject.AccessConnectio

' tried this at one time ... still got adOpenStati
' With c
' .Provider = "Microsoft.Access.OLEDB.10.0
' .CursorLocation = adUseServe
' .Properties("Data Provider").Value = "Microsoft.Jet.OLEDB.4.0
' .Properties("Data Source").Value = strpat
' .Ope
' End Wit

strSQL = "SELECT * From Address ORDER BY last_name
With Defrs
Set .ActiveConnection = c
.Source = "SELECT * From Address ORDER BY last_name
.LockType = adLockOptimisti
.CursorType = adOpenDynami
.CursorLocation = adUseServe
.Ope
End Wit

Set Me.Recordset = Defrs

Set Defrst = Nothin
Set cn = Nothin
GoTo Don

ErrorHandler
MsgBox Err.Descriptio
Done

End Su

Thanks again
 
G

Gerald Stanley

I have had problems in the past when setting recordset
cursor type and locking properties prior to populating it,
but all seems ok when declared in the open statement. Try
replacing
..Open
with
..Open ,,adOpenDynamic,adLockOptimistic

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
If anyone could give me some help that would be great!
I've been programming for years but I'm new to access and
figuring out ADO and DAO is quite confusing ... your help
would be much appreciated!!!
I'm having trouble binding an ADO recordset to a form.
Should I even be doing this? I've referred to (KB 281998),
but here's the problem: I want the recordset to be
adOpenDynamic (so the user can use custom buttons to do
prev/next/top/bottom/find and view all of the updated
records using the form). When I use code (like this below)
the locktype is reset to adOpenStatic???
 
M

mw

Gerald

Thanks for the suggestion ... I tried using the open statement with parameters, but still the locktype is static. Any other suggestions? Thanks again
Mary-An

Private Sub Form_Open(Cancel As Integer
'OPEN form with fields locked (open ... load ... activate .. current
Dim strpath As Strin
Dim strSQL As Strin
Dim cn As ADODB.Connectio
Dim Defrst As ADODB.Recordse

On Error GoTo ErrorHandle

'create cn connection (as stated in kb 281998
strpath = "C:\address\addressdb.mdb
Set cn = New ADODB.Connectio
With c
.Provider = "Microsoft.Access.OLEDB.10.0
.CursorLocation = adUseServe
.Properties("Data Provider").Value = "Microsoft.Jet.OLEDB.4.0
.Properties("Data Source").Value = strpat
.Ope
End Wit

'open recordse
Set Defrst = New ADODB.Recordse
strSQL = "SELECT * From Address ORDER BY last_name

Defrst.Open strSQL, cn, adOpenKeyset, adLockOptimisti

' o

'With Defrs
' Set .ActiveConnection = c
' .Source = strSQ
' .LockType = adLockOptimisti
' .CursorType = adOpenKeyse
' '.CursorLocation = adUseServe
' .Ope
'End Wit

Set Me.Recordset = Defrs

Set Defrst = Nothin
Set cn = Nothin
GoTo Don

ErrorHandler
MsgBox Err.Descriptio

Done

End Su


----- Gerald Stanley wrote: ----

I have had problems in the past when setting recordse
cursor type and locking properties prior to populating it
but all seems ok when declared in the open statement. Tr
replacing
..Open
wit
..Open ,,adOpenDynamic,adLockOptimisti

Hope This Help
Gerald Stanley MCS
-----Original Message----
If anyone could give me some help that would be great!
I've been programming for years but I'm new to access an
figuring out ADO and DAO is quite confusing ... your hel
would be much appreciated!!!Should I even be doing this? I've referred to (KB 281998)
but here's the problem: I want the recordset to b
adOpenDynamic (so the user can use custom buttons to d
prev/next/top/bottom/find and view all of the update
records using the form). When I use code (like this below
the locktype is reset to adOpenStatic??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top