I am trying to migrate Access 2003 (running fine) to Access 2007. The code written in VBA creates some issues. Like I have one main form and 2 subform. In main form recordsource set set by a Dynamic query but based on main form data when I am trying to set the Recordset of subform then access 2007 crash & close itself. Could you please help any one to find out why this occur in access 2007.
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's 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