A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How to use subfroms based on VBA.



 
 
Thread Tools Display Modes
  #1  
Old December 7th, 2009, 05:45 PM posted to microsoft.public.access.forms
fenners123
external usenet poster
 
Posts: 1
Default How to use subfroms based on VBA.

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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.