How to use subfroms based on VBA.

F

fenners123

Hi new to programming VBA in Access 2003.

I have a subform which has two comboboxes.

The first combobox uses the folowing rowsource.

SELECT Outputs_Classification.Output_id, Outputs_Classification.OutputClass
FROM Outputs_Classification;

The second combobox uses the afterupdate VBA code to select the rowsource of
the second combbobox as below.

Private Sub Form_Current()
Me!SB_combo.Requery
End Sub

Private Sub ServiceBenefit_combo_AfterUpdate()
Dim Physical As Integer, Output As Integer
Me.SB_combo = 0
Me.SB_combo.Requery
Output = ServiceBenefit_combo.Value
Forms![Service_Benefit_Classification]!SB_combo.RowSourceType = "Table/Query"
Forms![Service_Benefit_Classification]!SB_combo.RowSource = "SELECT
Service_Benefit_Categories.SB_id , Service_Benefit_Categories.
Service_Benefits FROM Service_Benefit_Categories WHERE SBid = " & CStr(Output)
& " ORDER BY Service_Benefit_Categories.Service_Benefits;"
Forms![Service_Benefit_Classification]!SB_combo.ColumnCount = "2"
Forms![Service_Benefit_Classification]!SB_combo.ColumnWidths = "0"
Forms![Service_Benefit_Classification]!SB_combo.ListRows = 27
End Sub


This works fine until I place the form as a subform in an other form.

Both forms are bound to the same table.

However the code does not work in the subform and I have read some threads
and placed the following in the MainForm OnLoad event, however with out
success.

Forms![Outputs Form]![Service_Benefit_Classification].Form!
[ServiceBenefit_combo].Requery
Forms![Outputs Form]![Service_Benefit_Classification].Form![SB_combo].Requery


Would be grateful for any advice?

Thanks fenners
 

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