Hi,
I am learning microsoft access and i was trying to work out how i can display the results of a query in a subform. my code is as follows:
Dim con As ADODB.Connection
Dim recSet As Recordset
Dim strFrmNm As String
Dim sqlQuery As String
Set recSet = New ADODB.Recordset
recSet.CursorType = adOpenKeyset
recSet.LockType = adLockOptimistic
Set con = CurrentProject.Connection
sqlQuery = "SELECT * FROM Video WHERE Video.Title='" & Me.vTitle.Value & "';"
recSet.Open sqlQuery, con
strFrmNm = "videoDetails"
DoCmd.OpenForm strFrmNm
' none of these commands seem to work
'Set Application.Forms(strFrmNm).Recordset = recSet
'Set Forms(strFrmNm).Recordset = recSet
'Set Forms!videoDetails.Recordset = recSet
'Set Me!Video.Form.Recordset = recSet
'Set Application.Forms("test")!Video.Form.Recordset = recSet
recSet.Close
con.Close
Set recSet = Nothing
Set con = Nothing
The issue i have is that when i press the button to execute my code data is displayed in a new form rather than the on the current forms subform. The primary form's name is test and the subform's name is videoDetails. The object name that contains the subform is Video.
I am learning microsoft access and i was trying to work out how i can display the results of a query in a subform. my code is as follows:
Dim con As ADODB.Connection
Dim recSet As Recordset
Dim strFrmNm As String
Dim sqlQuery As String
Set recSet = New ADODB.Recordset
recSet.CursorType = adOpenKeyset
recSet.LockType = adLockOptimistic
Set con = CurrentProject.Connection
sqlQuery = "SELECT * FROM Video WHERE Video.Title='" & Me.vTitle.Value & "';"
recSet.Open sqlQuery, con
strFrmNm = "videoDetails"
DoCmd.OpenForm strFrmNm
' none of these commands seem to work
'Set Application.Forms(strFrmNm).Recordset = recSet
'Set Forms(strFrmNm).Recordset = recSet
'Set Forms!videoDetails.Recordset = recSet
'Set Me!Video.Form.Recordset = recSet
'Set Application.Forms("test")!Video.Form.Recordset = recSet
recSet.Close
con.Close
Set recSet = Nothing
Set con = Nothing
The issue i have is that when i press the button to execute my code data is displayed in a new form rather than the on the current forms subform. The primary form's name is test and the subform's name is videoDetails. The object name that contains the subform is Video.