Go to the top of the page

I am trying to port Access 2003 (works fine) to Access 2007. Code written in VBA poses some problems. As I have one main form and 2 subforms. In the main form, the record set specified by the dynamic query, but based on the data of the main form, when I try to set the Recordset of subform, then go to crash 2007 and close it. Could you help someone find out why this happens in 2007 access.

Public Sub LoadRecord(strRecId As String)

On Error Resume Next

Dim ctl As Access.Control
Dim strsql As String
Dim strID As String
Dim rs As ADODB.Recordset

    strsql = "SELECT * from vwContractsMainForm WHERE ID = '" & strRecId & "'"

    Call OLEDBConnect 
    Set rs = New ADODB.Recordset
    With rs
        Set .ActiveConnection = cnn
        .Source = strsql
        .CacheSize = 1
        .LockType = adLockOptimistic
        .CursorType = adOpenKeyset
        .CursorLocation = adUseServer
        .Open
    End With

    'Set the first sub form Recordset property to the ADO recordset 
    Set Me.Recordset = rs   '-------- this part creates the problem.
    Me.UniqueTable = "tbl_contracts"
    Set rs = Nothing
    Set cnn = Nothing
+1
source share
1 answer

I will be damned. I learned something new about access this month. I never realized that you can change the recordset of this form.

On Error Resume Next, , , , , .

. strRecId ? ?

strRecoID cnn . , strID , , , , . Option Explicit . . , .

VBA, Tools โ†’ Options โ†’ , .

lurkers. , Microsoft. , , , , Service Packs.

+1

All Articles