changing the recoirdset of a subform

G

Guest

Hi all,
I have three combo boxes om a form which should dictate to the
subform what data to display. The first cboBox works fine but then the
recordsource for the subform is set for that cbobox. However I would like the
second cbobox (I have set this for 'on gotfocus') to change the recordsource
for the subform to a query I have created for this. Problem is i'm not having
any luck with the code....

Private Sub cboName_GotFocus()

Me.cboDrive = Null

Set rstNames = "qryNetInfoStaff"
rstNames.Open "Select * From qryNetInfoStaff"
Set Forms("sfmNetInfo").Recordset = rstNames
Forms("sfmNetInfo").UniqueTable = "qryNetInfoStaff"

DoCmd.Requery "sfmNetInfo"

End Sub


Can anyone please offer me any advice to get this to work.

Mitch.....
 
G

Guest

Don't confuse recordsets with recordsources. Here is the correct syntax:
Private Sub cboName_GotFocus()

Me.cboDrive = Null
Me!sfmNetInfo.Recordsource = "qryNetInfoStaff"
Me!sfmNetInfo.Requery

End Sub

The GotFocus event seems to be an unusual place to do this.
 
G

Guest

Yes !!
I just realised the gotfocus event and changed it to the afterUpdate event
on the cboBox.

thank you, I shall give this a go....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top