Updating a Subform based on a lst box

mcgrcoAgain

Registered User.
Local time
Today, 20:52
Joined
Jan 26, 2006
Messages
47
Hi, I know there are several posts all ready out there about this but i still can't resolve my problem. I have a list box populated on a form will values that aren’t related to the forms recordset. I then have a subform which is also unrelated to the main forms recordsource but is related to the listbox record source. When I added the subform I couldn't give it any relationship to the main form so I tried to set the forms recordsource in code based on the value in the list box. The code I’m using is below. The error message I get is Object doesn't support this property or method. Any help is really appreciated.


Private Sub lstEmailAddress_Click()
'Purpose: To populate the Medicorps Consulatants subform with the details of the email clicked in the list box
Dim strSql As String 'Sql to hold to set as the subforms record set

On Error GoTo Err


If IsNull(lstEmailAddress.Value) Then Exit Sub

strSql = ""
strSql = strSql & " SELECT [tbl Medicorps Consultant Contacts].*, [tbl Medicorps Consultant Contacts].Email"
strSql = strSql & " FROM [tbl Medicorps Consultant Contacts]"
strSql = strSql & " WHERE [tbl Medicorps Consultant Contacts].Email= '" & CStr(lstEmailAddress.Value) & "';"

Forms!frm_Main_DataEntryForm![frm_Medicorps_Consultants(Subform)].RecordSource = strSql

Forms!frm_Main_DataEntryForm![frm_Medicorps_Consultants(Subform)].Requery

Err_Exit:
Exit Sub

Err:
MsgBox Err.Description
Resume Err_Exit

End Sub
 

Users who are viewing this thread

Back
Top Bottom