The code below fill 2 list boxes from tables, But you should be able to modify it to your needs.
Function GetExampleList()
' This procedure is called from the OnOpen property setting of the
' Your form and from the OnChange event procedure for
' the tab control on the your form. It fills the list
' box control.
Dim frm As Form, ctlTab As TabControl
Dim ctlList As ListBox, ctlListExamples As ListBox
Dim strListSQL As String
On Error Resume Next
Set frm = Forms!YourForm
Set ctlListExamples = frm!lstExamples
strListSQL = "Select * FROM yourHyperformObjects
ctlListExamples.RowSource = strListSQL & ctlList.Column(0)
End Function
Function CheckIndex()
' This procedure is called from the OnChange property setting
' of the Your form. It forces the first item in the
' list box control on each tab to be selected if there is no current
' selection.
Dim ctlList As Control
Set ctlList = Screen.ActiveControl
If ctlList.Properties("ListIndex") = -1 Then
ctlList.Properties("ListIndex") = 0
End If
' Fill the examples list box.
GetExampleList
End Function
Function ClearList() As Integer
' This procedure is called from the OnUnload property of the
' yourform to clear the entries in the
' lstExamples list box control.
Dim frm As Form
Dim ctlList As ListBox
Set frm = Forms!yourForm
Set ctlList = frm!lstExamples
ctlList.RowSource = ""
End Function
Function GetExampleObject() As Integer
' This procedure is called from the OnClick property of the cmdOK button
' on the your form and gets the information needed to call
' the CreateHyperlink procedure below.
Dim frm As Form
Dim ctlList As ListBox, cmdOK As CommandButton
Dim objName As String, objType As String, strSubAddress As String
Set frm = Forms!YourForm
Set ctlList = frm!lstExamples
Set cmdOK = frm!cmdOK
If IsNull(ctlList.Column(2)) Then
MsgBox "Please select an example from the list."
Exit Function
Else
objName = ctlList.Column(2)
objType = ctlList.Column(3)
If objType = "Dialog" Then objType = "Form"
strSubAddress = objType & " " & objName
End If
' Web toolbar turned off here; otherwise it would appear
' automatically when the Follow method is invoked in the
' CreateHyperlink procedure.
DoCmd.ShowToolbar "Web", acToolbarNo
CreateHyperlink cmdOK, strSubAddress
End FunctionFunction GetExampleList()
' This procedure is called from the OnOpen property setting of the
' yourform form and from the OnChange event procedure for
' the tab control on the SolutionsHyperform form. It fills the list
' box control for the current tab.
Dim frm As Form, ctlTab As TabControl
Dim ctlList As ListBox, ctlListExamples As ListBox
Dim strListSQL As String
On Error Resume Next
Set frm = Forms!SolutionsHyperForm
Set ctlTab = frm!ctlTab
Set ctlListExamples = frm!lstExamples
strListSQL = "Select * FROM yourformObjects WHERE TopicID = "
ctlListExamples.RowSource = strListSQL & ctlList.Column(0)
End Function
Function CheckIndex()
' This procedure is called from the OnChange property setting
' of the Yourform form. It forces the first item in the
' list box control on each tab to be selected if there is no current
' selection.
Dim ctlList As Control
Set ctlList = Screen.ActiveControl
If ctlList.Properties("ListIndex") = -1 Then
ctlList.Properties("ListIndex") = 0
End If
' Fill the examples list box.
GetExampleList
End Function
Function ClearList() As Integer
' This procedure is called from the OnUnload property of the
' Yourform form to clear the entries in the
' lstExamples list box control.
Dim frm As Form
Dim ctlList As ListBox
Set frm = Forms!YourForm
Set ctlList = frm!lstExamples
ctlList.RowSource = ""
' Show your form if it is open but not Visible.
End Function
Function GetExampleObject() As Integer
' This procedure is called from the OnClick property of the cmdOK button
' on the SolutionsHyperform form and gets the information needed to call
' the CreateHyperlink procedure below.
Dim frm As Form
Dim ctlList As ListBox, cmdOK As CommandButton
Dim objName As String, objType As String, strSubAddress As String
Set frm = Forms!SolutionsHyperForm
Set ctlList = frm!lstExamples
Set cmdOK = frm!cmdOK
If IsNull(ctlList.Column(2)) Then
MsgBox "Please select an example from the list."
Exit Function
Else
objName = ctlList.Column(2)
objType = ctlList.Column(3)
If objType = "Dialog" Then objType = "Form"
strSubAddress = objType & " " & objName
End If
' Web toolbar turned off here; otherwise it would appear
' automatically when the Follow method is invoked in the
' CreateHyperlink procedure.
DoCmd.ShowToolbar "Web", acToolbarNo
CreateHyperlink cmdOK, strSubAddress
End Function
Never give up never give in.
There are no short cuts to anything worth doing
