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  

subforms/combo boxes



 
 
Thread Tools Display Modes
  #1  
Old September 24th, 2007, 02:32 PM posted to microsoft.public.access.forms
misschanda via AccessMonster.com
external usenet poster
 
Posts: 111
Default subforms/combo boxes

I have form1 that has a subform and a macro that opens up form2. Form2 has
cascading combo boxes, with the final choice needing to be represented in the
subform on form1.. How can I input the final choice on form 2 to that of the
subform on form1???

Thanks
LA

--
Message posted via http://www.accessmonster.com

  #2  
Old September 24th, 2007, 03:15 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default subforms/combo boxes

You could put code in the AfterUpdate event of the last combo box on Form2.

Something like:

Private Sub MyCombo_AfterUpdate()

Forms!Form1!SubformControlName.Form!ControlOnSubfo rmName = Me.MyCombo

End Sub

Note that depending on how you added the subform to Form1, the name of the
subform control may not be the same as the name of the form being used as a
subform.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"misschanda via AccessMonster.com" u36612@uwe wrote in message
news:78b297f6e04f2@uwe...
I have form1 that has a subform and a macro that opens up form2. Form2 has
cascading combo boxes, with the final choice needing to be represented in
the
subform on form1.. How can I input the final choice on form 2 to that of
the
subform on form1???

Thanks
LA

--
Message posted via http://www.accessmonster.com



  #3  
Old September 24th, 2007, 03:28 PM posted to microsoft.public.access.forms
NKTower
external usenet poster
 
Posts: 95
Default subforms/combo boxes

To keep track of the players, let's assume form 1's name is: "My Form 1"
with subform named "subform_in_Form_1" Note that this is the name
of the object as referenced withing Form1, not necessarily the name of the
form defintiion in the FORMS container of the database window.
Lastly, in form2 your final combo box is named "cbo_Final".

In form2's code behind the forms
' =======================
Private Sub cbo_Final_Click()
Dim frm1 As Form
Dim sfm1 As Form

' Make sure the form is loaded to receive the message...
If Not CurrentProject.AllForms("My Form 1").IsLoaded Then
Set frm1 = Forms![My Form 1].Form
Set sfm1 = frm1.[subform_in_Form_1].Form

' You may now reference the contents of the subform. For example you may
change the FILTER property, or the RECORDSOURCE property.
-----
' Example 1
sfm1.Filter = "[something] = " & Me.cbo_Final
sfm1.FilterOn = True
-----
' Example 2
Dim SQL As String
SQL = "SELECT ..... FROM .... WHERE [something] = " & Me.cbo_Final
sfm1.Recordsource = SQL
-----
Set frm1 = Nothing
Set sfm1 = Nothing
Else
MsgBox "Oops. My Form 1 not loaded.",vbOkOnly+vbCritical,"Error"
End If
End Sub
' ===================

"misschanda via AccessMonster.com" wrote:

I have form1 that has a subform and a macro that opens up form2. Form2 has
cascading combo boxes, with the final choice needing to be represented in the
subform on form1.. How can I input the final choice on form 2 to that of the
subform on form1???

Thanks
LA

--
Message posted via http://www.accessmonster.com


 




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 11:18 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.