Calling a Subform

  • Thread starter Thread starter Graham Naylor
  • Start date Start date
G

Graham Naylor

Hi,

I've got a form with a subform and a Combo Box, I would like to change the
record source of the subform depending on the value selected in the Combo
box.

I've got as putting some code in the combo box's after update procedure but
I can't work out the correct syntax for changing the subform's record
source.

Any help would be much appreciated.

Thanks

Graham
 
Here's some code from a Frame. You should be able to
adapt it to the ComboBox result you get.

Private Sub Frame527_AfterUpdate()
Dim M$
bNeedDrug = False: bNeedInvDate = False
Select Case Frame527
Case 0
Exit Sub
Case 1
If Not IsNull(cboTheDrug) Then
M = "BrandName = """ & cboTheDrug & """"
Me.SubMeds.Form.RecordSource = "ForMeds"
Me.SubMeds.Form.Filter = M
Me.SubMeds.Form.FilterOn = True
Else
bNeedDrug = True
MsgBox "Please Select A Drug.", , "MAP"
cboTheDrug.SetFocus: cboTheDrug.Dropdown
End If
Case 2
Me.SubMeds.Form.RecordSource = "InvoiceMeds"
Case 3
Me.SubMeds.Form.RecordSource = "ForMeds"
Me.SubMeds.Form.OrderBy = "BrandName, InvDate DESC"
Me.SubMeds.Form.OrderByOn = True
Me.SubMeds.Form.FilterOn = False
Case 4
Me.SubMeds.Form.RecordSource = "MostRecentMeds"
'Me.SubMeds.Form.Requery
Case 5
If Not IsNull(cboInvDate) Then
M = "InvDate = #" & cboInvDate & "#"
Me.SubMeds.Form.RecordSource = "ForMeds"
Me.SubMeds.Form.Filter = M
Me.SubMeds.Form.FilterOn = True
Else
bNeedInvDate = True
MsgBox "Please Select An InvDate.", , "MAP"
cboInvDate.SetFocus: cboInvDate.Dropdown
End If
End Select
End Sub

HTH - Bob
 
Thanks Bob, all up and running, yet another case of so near but so far!

Graham
 
Back
Top