Set Recordsource for a Subform using VBA

schu7044

Registered User.
Local time
Today, 06:52
Joined
Jan 31, 2008
Messages
14
Hi: I am new to this forum. I hope someone can help me out.

I am attempting to set the recordsource for a subform using VBA. I am receiving the following error: Compile error: Syntax error

I am using the following code:

' Ensure a group has been selected
If IsNull(Forms!frmCiaGroups1.cboSelectedGroup) Then
Call NoGroupEntered
Exit Function
End If ' for Group Not Entered

Dim strGroup As String

Dim dbs As DAO.Database
Dim qdf As QueryDef

Set dbs = CurrentDb()

strGroup = "'" & Forms!frmCiaGroups1![GroupSymbol] & "'"

Forms!frmCiaGroups1!frmCiaGroupsSub.RecordSource = "SELECT * FROM qryCIA_Group_Sub WHERE Left([TxGroup],3)" & = & strGroup

Thank you for your help, Don
 
It would help if you mentioned which line you were getting the error on but...

instead of
Forms!frmCiaGroups1!frmCiaGroupsSub.RecordSource = ...

try

Forms!frmCiaGroups1.frmCiaGroupsSub.Form.RecordSource = ...

[edit] damned if I know why the forum is adding a space within the word 'recordsource' but it is not meant to be there
 
Yes!! Thank you!

Sorry about not identifing the error line, but you nailed it.

Thanks again, Don
 

Users who are viewing this thread

Back
Top Bottom