Solved

clear subform

Posted on 2016-09-27
2
22 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 119

Accepted Solution

by:
Rey Obrero earned 250 total points
Comment Utility
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 18

Assisted Solution

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now