UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Syntax To Address Subform On Some Other Form, Access 2016    
 
   
fizzy1
post Jul 17 2019, 08:18 PM
Post#1



Posts: 510
Joined: 26-May 11



Hi,

I'm trying to refresh/requery (not sure which is appropriate) a subform ("subfrmInventoryTransactionsByPart") on some other form ("frmItemSingle"). I'm getting an error that says it cannot find that form:

Attached File  Screenshot_2019_07_17_19.12.25.png ( 9.78K )Number of downloads: 0


The form really does exist, and I can get it to confirm that it does find it with:
If CurrentProject.AllForms("frmItemSingle").IsLoaded Then MsgBox "form is loaded" <-- which does fire just fine

The code I'm trying to get to run is:
If CurrentProject.AllForms("frmItemSingle").IsLoaded Then Forms!frmItemSingle!subfrmInventoryTransactionsByPart.Form.Requery

I think that should be correct but I get that error.

Could someone please suggest a fix for my syntax, or whatever is driving the error?

Thanks,
Toby.

--------------------

thanks,
fizzy1.
Go to the top of the page
 
Doug Steele
post Jul 17 2019, 08:29 PM
Post#2


UtterAccess VIP
Posts: 22,182
Joined: 8-January 07
From: St. Catharines, ON (Canada)


Are you certain that the name of the subform control is subfrmInventoryTransactionsByPart? Depending on how the form was added as a subform, it's possible that the subform control name may be different from the name of the form being displayed in the control. You must use the name of the control, as in Forms!frmItemSingle!subfrmInventoryTransactionsByPartControlName.Form.Requery

If that still doesn't work, try Forms!frmItemSingle!subfrmInventoryTransactionsByPartControlName.Requery

--------------------
Doug Steele, Microsoft Access MVP (2000-2018)
Personal webpage
Microsoft profile
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Co-author: Effective SQL: 61 Specific Ways to Write Better SQL, published by Addison-Wesley Professional
Technical Editor: Access 2010 Bible, Access 2013 Bible, Access 2016 Bible, all published by Wiley
Technical Editor: SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition, published by Addison-Wesley Professional
Go to the top of the page
 
fizzy1
post Jul 17 2019, 10:04 PM
Post#3



Posts: 510
Joined: 26-May 11



Hi Doug,

I'm certain the subform control is called "subfrmInventoryTransactionsByPart" (and in code it can have either of two forms as it's source object, "frmInventoryTransactionsByPart" and "frmInventoryTotalsByLocation"). I should probably tidy up the name of the subform control a bit, but it is correct.

Thanks,
Toby,

--------------------

thanks,
fizzy1.
Go to the top of the page
 
Doug Steele
post Jul 18 2019, 04:33 AM
Post#4


UtterAccess VIP
Posts: 22,182
Joined: 8-January 07
From: St. Catharines, ON (Canada)


Just re-read the error message you posted, and it looks as though Access is complaining about the name of the parent form, not the subform. Is it possible your parent form isn't actually named frmItemSingle: that there's a typo in its name, for instance?

--------------------
Doug Steele, Microsoft Access MVP (2000-2018)
Personal webpage
Microsoft profile
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Co-author: Effective SQL: 61 Specific Ways to Write Better SQL, published by Addison-Wesley Professional
Technical Editor: Access 2010 Bible, Access 2013 Bible, Access 2016 Bible, all published by Wiley
Technical Editor: SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition, published by Addison-Wesley Professional
Go to the top of the page
 
fizzy1
post Jul 18 2019, 10:12 AM
Post#5



Posts: 510
Joined: 26-May 11



Hi Doug,

The form name is typed correctly. To confirm, I even copied it from the object list. Also, Access does recognize that because I can address (and find it) simply with:
If CurrentProject.AllForms("frmItemSingle").IsLoaded Then MsgBox "form is loaded"
which fires the msgbox correctly.

However, I tried to do something to the form itself, just to simplify the problem, and this fails with the same error message:
If CurrentProject.AllForms("frmItemSingle").IsLoaded Then Forms!frmItemSingle.Caption = "this is a test"

The form is definitely loaded, but I can't manipulate it. Weird.

Thanks,
Toby

--------------------

thanks,
fizzy1.
Go to the top of the page
 
fizzy1
post Jul 19 2019, 06:22 PM
Post#6



Posts: 510
Joined: 26-May 11



Doug,

I've discovered there's a multi-instance situation managing the form I'm trying to address, which is causing my inability to address the form the way I'm trying. Apologies for this red herring thread. Solved.

Thanks,
Toby.

--------------------

thanks,
fizzy1.
Go to the top of the page
 
Doug Steele
post Jul 19 2019, 07:09 PM
Post#7


UtterAccess VIP
Posts: 22,182
Joined: 8-January 07
From: St. Catharines, ON (Canada)


Glad you solved your problem!

--------------------
Doug Steele, Microsoft Access MVP (2000-2018)
Personal webpage
Microsoft profile
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Co-author: Effective SQL: 61 Specific Ways to Write Better SQL, published by Addison-Wesley Professional
Technical Editor: Access 2010 Bible, Access 2013 Bible, Access 2016 Bible, all published by Wiley
Technical Editor: SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition, published by Addison-Wesley Professional
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    17th August 2019 - 07:45 AM