Solved

Change subforms source object and goto record

Posted on 2008-10-14
7
569 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
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

821 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