Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing a subform

Status
Not open for further replies.

crystalreporting

Instructor
Joined
Feb 13, 2003
Messages
649
Location
NZ
I searched the archives but couldn't find an answer;

I have a simple main form that captures part number and qty. and stores it in a table. When a new part number is entered, I want to display the part description and UOM - this data exists in a different table, linked by part number on a 1-1 relationship.

I've created a query and added it to my form. If I scroll through records I've already added, the description and UOM display fine in the sub-form. However, when I'm entering an item the information does not display. I'd like the description and UOM to be displayed as the information is being entered on the main form i.e. tab off the part number on the main form, refresh the query/subform.

What do I need to do? Thanks - Peter.

Peter Shirley
 
Use the 'after update' event of the control you want to trigger the subform refresh. Personally, I like to set the recordsource of the subform...

private sub textbox_afterupdate()
me.subform.form.recordsource = _
"SELECT * FROM mytable WHERE mytable.myfield1 = " & me.textbox

end sub

Hope that helps,
Gary
gwinn7
 
Gary,

Thanks for responding!

I'm having a little trouble with the syntax - if my main form is Tag_Entry, and my subform is Item_Details how does that fit in with the syntax you outlined.

Sorry for the noobie questions.

Peter.

Peter Shirley
 
Peter,

In my example...

me.subform.form.recordsource

The "subform" is the name of the control that hosts the subform. You don't have to directly reference either form. Here is another way of putting it....

Me.<your subform control name>.form.recordsource

After specifying your subform control, you need to then reference the object's form object. The "Form" object has the property, as others, of "recordsource".

That should help you.
Gary
gwinn7
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top