christakis
Registered User.
- Local time
- Today, 13:03
- Joined
- Oct 23, 2009
- Messages
- 72
Hi guys,
I have a table:
tblDeviceClasses
->Key
->Name
->Path
->DeviceClassForm
In my main form, I have a listbox which looks up this table and shows a list of the names. The Key is the bound column and is hidden. I want to select one item from the list and when i click a button to open the corresponding form to the item (DeviceClassForm).
I thought I would SQL search the table based on the returned value of the list (key), obtain the name of the form, and then open it. Here is the code I came up. Doesnt work but im preety sure im close.
Any help is appreciated
Cheers,
Chris
I have a table:
tblDeviceClasses
->Key
->Name
->Path
->DeviceClassForm
In my main form, I have a listbox which looks up this table and shows a list of the names. The Key is the bound column and is hidden. I want to select one item from the list and when i click a button to open the corresponding form to the item (DeviceClassForm).
I thought I would SQL search the table based on the returned value of the list (key), obtain the name of the form, and then open it. Here is the code I came up. Doesnt work but im preety sure im close.
Code:
Private Sub btnOpenClass_Click()
On Error GoTo Err_btnOpenClass_Click
Dim stLinkCriteria As String
Dim strSQL As String
Dim formName As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
strSQL = "Select * from tblDeviceClasses where Key = '" & Me.listClasses & "'"
rs.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
formName = rs!DeviceClassForm
DoCmd.OpenForm formName, , , stLinkCriteria
Exit_btnOpenClass_Click:
Exit Sub
Err_btnOpenClass_Click:
MsgBox Err.Description
Resume Exit_btnOpenClass_Click
End Sub
Any help is appreciated
Cheers,
Chris
Last edited: