Solved

Change subforms source object and goto record

Posted on 2008-10-14
7
571 Views
Last Modified: 2013-11-28
I am trying to change the source object of a subform on a mainform but need to go to a specific record when the source object has changed. The event is fired from the subform when a user clicks on a field I would like the subform source object to change and the record associated with that field to be shown on the changed subform.

So far I have used the following and I have tried everything this evening to get it working with little success. At the moment it throws up a error message method or data not found on Me.Subform which is the name of the unbound subform.

Any help would be much appreciated


Forms.swbEquipment!Subform.SetFocus
   Me.Subform.SourceObject = "subfrmGRMachineryDetails"
   Me.Subform.Filter = "UnitID=" & Me![UnitID]
   Me.Subform.FilterOn = True

Open in new window

0
Comment
Question by:MGardner
[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
  • 5
  • 2
7 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 22715691
Change the Name property of the actual subform Control on the Main form ... to something like

fsub01 ... then try this:

Forms.swbEquipment!fsub01.SetFocus
   Me.fsub01.SourceObject = "subfrmGRMachineryDetails"
   Me.fsub01.Filter = "UnitID=" & Me![UnitID]
   Me.fsub01.FilterOn = True

mx
0
 
LVL 2

Author Comment

by:MGardner
ID: 22715917
Thanks for that mx but it is still coming up with method or data member not found on Me.fsub01
0
 
LVL 75
ID: 22715939
Can you Compact & Repair (to shrink the size), then zip up the MDB, then attach the file for upload here  ... removing any sensitive data of course? And please give a clear exlpanation of exactly how to reproduce the problem.

mx
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 2

Author Comment

by:MGardner
ID: 22716016
Will do but might take a little time
0
 
LVL 2

Author Comment

by:MGardner
ID: 22725911
Hi mx

sorry for the delay but unfortunately some presing personal matters to attend to this evening but here is the slimmed down db
Log in as user: Admin Password: Admin and hit the equipment tab.
Say yes to view the machine service dues
Click on the machine name/description to take you to the machine details and this is where it throws up the error message.

Thanks for your help

mg
New-H-S-Db-August2008.zip
0
 
LVL 2

Author Comment

by:MGardner
ID: 22735670
Any thoughts on this mx? or am I asking the impossible. I did wonder if the problem was with changing the source object before the code has time to fully work its way to the end.
0
 
LVL 2

Author Comment

by:MGardner
ID: 23088943
I have managed to work around the problem with adding a second sub form where the objects source is called from the parent form and is then made visible. The second form I named fsub02. This was the only way that I could think of to get around the problem though not as elegant as I would have hoped but thanks for what help you gave in any case mx
Dim lngUnitID
Dim sFrm As Form
lngUnitID = Me.txtUnitID
Forms.swbEquipment.fsub02.SourceObject = "subfrmGRMachineryServicefrm"
Set sFrm = Forms.swbEquipment!fsub02.Form
sFrm.Visible = True
Forms.swbEquipment.SetFocus
Forms.swbEquipment!fsub02.SetFocus
sFrm.RecordsetClone.FindFirst "[UnitID]= " & lngUnitID
If Not sFrm.RecordsetClone.NoMatch Then
      sFrm.Bookmark = sFrm.RecordsetClone.Bookmark
ElseIf sFrm.RecordsetClone.NoMatch Then
 
Forms.swbEquipment.fsub02.SourceObject = "subfrmGRMachineryServicefrmAddNew"
 
Forms.swbEquipment!fsub02.Visible = True
 
End If
Forms.swbEquipment!fsub01.Form.Visible = False

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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 …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

636 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