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  

Combo Box results to Subform



 
 
Thread Tools Display Modes
  #1  
Old October 13th, 2009, 06:03 PM posted to microsoft.public.access.forms
Humbled Learner
external usenet poster
 
Posts: 36
Default Combo Box results to Subform

I created a form with a combo box (names)
The form has a suboform, (orders subform)
When I select a name from the form, the subform reports only those rows
attached to that name.

My problem is... when you open the form and the combo box is blank, but the
subform shows all rows attached to the first name.

Can I make the subform blank until a name is chosen, or can I have the
subform show all rows until a name is chosen.

The combo box reflects:

After Update:
Option Compare Database

Private Sub Combo4_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[NameID] = " & Str(Nz(Me![Combo4], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub



Thank You
  #2  
Old October 13th, 2009, 06:33 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Combo Box results to Subform

If your subform is based on a query, and if that query is based on the value
selected, then you won't have any value select (and hence, no subform
records) until the select is made in the combobox.

You'll need to requery after the selection is made (use the AfterUpdate
event of the combobox).

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"Humbled Learner" wrote in
message ...
I created a form with a combo box (names)
The form has a suboform, (orders subform)
When I select a name from the form, the subform reports only those rows
attached to that name.

My problem is... when you open the form and the combo box is blank, but
the
subform shows all rows attached to the first name.

Can I make the subform blank until a name is chosen, or can I have the
subform show all rows until a name is chosen.

The combo box reflects:

After Update:
Option Compare Database

Private Sub Combo4_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[NameID] = " & Str(Nz(Me![Combo4], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub



Thank You



 




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 02:24 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.