dbTalk Databases Forums  

Subform Question

comp.database.ms-access comp.database.ms-access


Discuss Subform Question in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kirkm
 
Posts: n/a

Default Subform Question - 07-24-2007 , 01:18 AM






Wonder if someone can assist here, please?

I have a Form which I've dragged onto another Form
to have several things on the Form at once.

I've called this 'subfrmUS'. And set it's Source Object to frmUS.

frmUS has it's record source set to Query1

A selection is made from a combo box and resultant sql built which is
assigned to Query1.

My aim is to have subfrmUS display query1.

Both Query1 and frmUS display the right thing.

However nothing will make subfrmUS show query1 - except once when the
Form is first opened.

I've spend hours with 'Requery' but that doesn't seem to work.

Any ideas?

Thanks - Kirk


Reply With Quote
  #2  
Old   
John Mishefske
 
Posts: n/a

Default Re: Subform Question - 07-25-2007 , 07:13 PM






kirkm wrote:
Quote:
I have a Form which I've dragged onto another Form
to have several things on the Form at once.

I've called this 'subfrmUS'. And set it's Source Object to frmUS.

frmUS has it's record source set to Query1

A selection is made from a combo box and resultant sql built which is
assigned to Query1.

My aim is to have subfrmUS display query1.

Both Query1 and frmUS display the right thing.

However nothing will make subfrmUS show query1 - except once when the
Form is first opened.
Based on what you wrote it sounds like you want the subform (frmUS) to
..Requery the databases after the user has updated the value of a combo
box on the main form.

Here is what I would do and it sounds that this approach may be what
you've tried. Perhaps my example will help determine the problem.

You want all this to happen after the combo box on the main form is
updated so that control's AfterUpdate event is the appropriate to place
this code.

You state the subform's displays correctly when the form is opened. What
if you navigate record's on the main form (if the main form is is bound
to a record source)? You may need to also requery on the main form's
OnCurrent event. Assuming you may need to run the same code from two (or
more) different events I wrote a procedure (a Sub):

Private Sub requerySubForm()

With Me!subfrmUS
.SetFocus
.Form.Requery
End With

End Sub

Put this code in the code behind your main form.

Now you can call this proc from the appropriate event, for example, if
you combobox is named cboMyCombo then its AfterUpdate event code might
look like this:

Private Sub cboMyCombo_AfterUpdate()
requerySubForm
End Sub

and the main form's OnCurrent event might look like this:

Private Sub Form_OnCurrent()
requerySubForm
End Sub



--
'--------------------------
' John Mishefske
' UtterAccess Editor
' 2007 Microsoft Access MVP
'--------------------------


Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.