Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

clear subform

Posted on 2016-09-27
2
Medium Priority
?
50 Views
Last Modified: 2016-10-06
Access 2010:
I have a subform: but it is not master child linked.

This is the name:
dbo_t_redbook_pricing_escalation_detail_subform

This is the "source Object" :
dbo_t_redbook_pricing_escalation_detail_subform

I'm trying to clear the subform out...
But it just appears white and blank..

by using.
Dim temp As String
temp = ""
temp = dbo_t_redbook_pricing_escalation_detail_subform.SourceObject
dbo_t_redbook_pricing_escalation_detail_subform.SourceObject = temp

me.dbo_t_redbook_pricing_escalation_detail_subform.requery

I want to clear it as if i just opened the database. form

trying to reset the recordsource via sql but saying it is to complex ?
Dim strSQL As String
strSQL = "SELECT TOP 5 dbo_t_redbook_pricing_escalation_detail.[AUTO_ID], dbo_t_redbook_pricing_escalation_detail.[RBP_MASTER_ID], dbo_t_redbook_pricing_escalation_detail.[SKU], dbo_t_redbook_pricing_escalation_detail.[PRODUCT_DESCRIPTION], dbo_t_redbook_pricing_escalation_detail.[QTY], dbo_t_redbook_pricing_escalation_detail.[TARGET_PRICE], dbo_t_redbook_pricing_escalation_detail.[COMPETITOR_PRICE], dbo_t_redbook_pricing_escalation_detail.[TARGET_GP], dbo_t_redbook_pricing_escalation_detail.[CURRENT_PRICE], dbo_t_redbook_pricing_escalation_detail.[CURRENT_GP], dbo_t_redbook_pricing_escalation_detail.[VENDOR_GUIDELINE_GP], dbo_t_redbook_pricing_escalation_detail.[APPROVED_PRICE], dbo_t_redbook_pricing_escalation_detail.[APPROVED_GP] From dbo_t_redbook_pricing_escalation_detail WHERE dbo_t_redbook_pricing_escalation_detail.RBP_MASTER_ID= [Forms]![Main]![PRICING_ESCALATION_ID]"
Me.dbo_t_redbook_pricing_escalation_detail_subform.Form.RecordSource = strSQL




Thanks
fordraiders
0
Comment
Question by:fordraiders
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 41818946
try this

Dim strSQL As String
 strSQL = "SELECT TOP 5 dbo_t_redbook_pricing_escalation_detail.[AUTO_ID], dbo_t_redbook_pricing_escalation_detail.[RBP_MASTER_ID], dbo_t_redbook_pricing_escalation_detail.[SKU], dbo_t_redbook_pricing_escalation_detail.[PRODUCT_DESCRIPTION], dbo_t_redbook_pricing_escalation_detail.[QTY], dbo_t_redbook_pricing_escalation_detail.[TARGET_PRICE], dbo_t_redbook_pricing_escalation_detail.[COMPETITOR_PRICE], dbo_t_redbook_pricing_escalation_detail.[TARGET_GP], dbo_t_redbook_pricing_escalation_detail.[CURRENT_PRICE], dbo_t_redbook_pricing_escalation_detail.[CURRENT_GP], dbo_t_redbook_pricing_escalation_detail.[VENDOR_GUIDELINE_GP], dbo_t_redbook_pricing_escalation_detail.[APPROVED_PRICE], dbo_t_redbook_pricing_escalation_detail.[APPROVED_GP] From dbo_t_redbook_pricing_escalation_detail WHERE dbo_t_redbook_pricing_escalation_detail.RBP_MASTER_ID= " & [Forms]![Main]![PRICING_ESCALATION_ID]
Me.dbo_t_redbook_pricing_escalation_detail_subform.Form.RecordSource = strSQL


also, take note that the subform loads first before the main form, so place the codes in the Load event of the main form or in the
current event if it deems necessary.

why not use master/child link fields?
0
 
LVL 22

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 1000 total points
ID: 41827453
>"But it just appears white and blank.."

is AllowAdditions set to True? If not, and there is not a record, the form will be as you describe.

also, Rey suggested setting LinkMasterFields and LinkChildFields for the subform control (DATA tab  of Properties) ... let Access do the hard work ;) ~ Just make sure that what you reference is ON each form (it can be Visible=No). LinkMasterFields references a control and it can even be calculated. LinkChildFields must be a field in the RecordSource for the subform. If you have more than one to list, separate with ; (semi-colon)
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question