Solved

Change subforms source object and goto record

Posted on 2008-10-14
7
562 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

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 the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
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…

746 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