All,
I'm having great difficulty working out the syntax to change the Recordset on a Subform. I'll try my best to explain.
I have a 'Menu' subform which gets it's recordset from an ADO recordset, it's a continuous form using a Textbox for he list of options.
The problem I'm having is, I'm using the same form to display a different list of menu options from a different table, but, the using the same recordset.
Here is the code to create the recordset.
When the subform loads it uses the first case as the recordset and I have the Textbox ControlSource as 'Heading'
What I'm trying to do is, when the user click a button rsMenu then picks up the second case from the database and the menu should change.
I have had no problem setting the ControlSource of the textbox to 'DSO' but I can't figure out how to re-Set the Recordset so it knows that 'DSO' is a field which can be used.
I'm assuming this is what I need to do as currently, when the button is clicked is displays #Name?, as the ControlSource has changed no problem but it obviously doesn't see the recordset as having that field in it.
Here is the code (including failed syntax) I am using:
I hope I've been able to explain my question correctly.
Any help is appreciated.
Thanks,
I'm having great difficulty working out the syntax to change the Recordset on a Subform. I'll try my best to explain.
I have a 'Menu' subform which gets it's recordset from an ADO recordset, it's a continuous form using a Textbox for he list of options.
The problem I'm having is, I'm using the same form to display a different list of menu options from a different table, but, the using the same recordset.
Here is the code to create the recordset.
Code:
Public Sub GetMenu()
Dim strSQL As String
Call OpenConn
Set rsMenu = New ADODB.Recordset
Select Case intMenu
Case 1
strSQL = "SELECT HeadingID, Heading, Active, HeadingDesc FROM FRKHeading;"
Case 2
strSQL = "SELECT DSO, Active FROM DSO;"
End Select
With rsMenu
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockBatchOptimistic
.Open strSQL, conn
.ActiveConnection = Nothing
End With
Call CloseConn
End Sub
When the subform loads it uses the first case as the recordset and I have the Textbox ControlSource as 'Heading'
What I'm trying to do is, when the user click a button rsMenu then picks up the second case from the database and the menu should change.
I have had no problem setting the ControlSource of the textbox to 'DSO' but I can't figure out how to re-Set the Recordset so it knows that 'DSO' is a field which can be used.
I'm assuming this is what I need to do as currently, when the button is clicked is displays #Name?, as the ControlSource has changed no problem but it obviously doesn't see the recordset as having that field in it.
Here is the code (including failed syntax) I am using:
Code:
Private Sub cmdDictMan_Click()
intMenu = 2
Call GetMenu
'Set Forms("frmMain").Controls("sfrmMenu").RecordSource = rsMenu
'Set Forms![frmMain]![sfrm1].Recordset = rsMenu
Forms![frmMain].Controls("sfrmMenu").Controls("txtMenuItem").ControlSource = "DSO"
'Forms![frmMain].Controls("sfrmMenu").Requery
End Sub
I hope I've been able to explain my question correctly.
Any help is appreciated.
Thanks,