Solved

clear subform

Posted on 2016-09-27
2
42 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
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 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 20

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 250 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

685 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