Solved

Change subforms source object and goto record

Posted on 2008-10-14
7
563 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 - Access MVP) 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 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

13 Experts available now in Live!

Get 1:1 Help Now