Hi,
I am having trouble trying to get a subform to show a record selected from listbox on the main form.
Using the list box, when I click on the desired info, I can get a seperate form (InstructorList) to open and show the complete record using the following code:
In the listbox rowsource:
in the On Double Click event:
When I try to embed the form InstructorList as a subform (using the wizard) on the main form (InstructorView) , I can't get it to populate using the following code in the afterupdate event:
It gives me a visual basic error message "Run-Time error '424' Object required" and highlights the line Form_Instructorlist.RecordSource = LSQL when I debug.
I'm at a loss to figure it out. Any help would be appreciated.
Thanks
I am having trouble trying to get a subform to show a record selected from listbox on the main form.
Using the list box, when I click on the desired info, I can get a seperate form (InstructorList) to open and show the complete record using the following code:
In the listbox rowsource:
Code:
SELECT [Instructor Info].Instructor_ID, [Instructor Info].Rank, [Instructor Info].Last_Name, [Instructor Info].First_Name, [Instructor Info].Middle_Initial FROM [Instructor Info];
in the On Double Click event:
Code:
Private Sub List0_DblClick(Cancel As Integer)
DoCmd.openform "InstructorList", , , "[Instructor Info].[Instructor_ID]=" & Me.List0.Column(0)
DoCmd.close acForm, "InstructorSearch"
End Sub
When I try to embed the form InstructorList as a subform (using the wizard) on the main form (InstructorView) , I can't get it to populate using the following code in the afterupdate event:
Code:
Option Compare Database
Sub SetFilter()
Dim LSQL As String
LSQL = "select * from InstructorInfo"
LSQL = LSQL & " where Instructor_ID = '" & List0 & "'"
Form_InstructorList.RecordSource = LSQL
End Sub
Private Sub List0_AfterUpdate()
'Call subroutine to set filter based on selected last name
SetFilter
End Sub
Private Sub Form_Open(Cancel As Integer)
'Call subroutine to set filter based on selected last name
SetFilter
End Sub
It gives me a visual basic error message "Run-Time error '424' Object required" and highlights the line Form_Instructorlist.RecordSource = LSQL when I debug.
I'm at a loss to figure it out. Any help would be appreciated.
Thanks