Andy Lacey
andy at minstersystems.co.uk
Tue Dec 7 07:35:47 CST 2004
Sorry Doris, but it's not silly. This is why: 1.If you have, say, 20 forms which all set the caption dynamically and have no other code then you can lose 20 modules (CBF modules that is) out of your MDB and have 20 lightweight forms that previously weren't. The function they all call can be in a module with other code so it doesn't even cost a module there. 2.As I tried to explain in my original post the real-life usage would not be to pass the caption as text (that WOULD be silly) but to pass the result of a function call, in order to set the form's caption to, say, a customer name or something similar. So a real application of this might be: =SetCaption([Screen].[ActiveForm], fnProduct()) 3.You can't pass Me as a reference to the current form when you're using a function call rather than an Event Procedure. I stress again that I'm trying to lose code, so all that's in the Event is: =SetCaption([Screen].[ActiveForm],"x") What is decidedly not there is [Event Procedure] leading to code. -- Andy Lacey http://www.minstersystems.co.uk --------- Original Message -------- From: Access Developers discussion and problem solving <accessd at databaseadvisors.com> To: 'Access Developers discussion and problem solving' <accessd at databaseadvisors.com> Subject: RE: [AccessD] Set form's Caption without code Date: 07/12/04 14:19 > > Okay... This exercise seems a little silly to me because it doesn't seem to > make sense to create three lines of code somewhere else to do something that > only takes one line. Particularly when you have to pass in the caption you > want as part of the process. > > If you insist on doing this, try just passing Me (the form object) and the > caption. > > Doris Manning > Database Administrator > Hargrove Inc. > www.hargroveinc.com > > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Andy Lacey > Sent: Tuesday, December 07, 2004 5:59 AM > To: Dba > Subject: [AccessD] Set form's Caption without code > > > Ok, here's the thing. I want to make a few forms lightweight which currently > have just a line or two in modules. A few have nothing more than a line > which dynamically sets the form's caption. So I wrote a little function like > this: > > Function SetCaption(frm As Form, strCaption As String) frm.Caption = > strCaption End Function > > and then changed my form's OnOpen from being an Event Procedure to : > > =SetCaption([Screen].[ActiveForm],"x") > > (The "x" is just for testing. The real call would have something a bit more > dynamic, like the result of a function call.) > > The thing is that it errors because it can't resolve [Screen].[ActiveForm] > at that point. Ok, methinks, I'll move the call. But I can't find where to > put it. All of the following fail: > > On Load > On GotFocus of the first control > On Current > > The only success I've had is putting a timer interval of 5 and putting the > call in OnTimer, but I don't like that much as you can imagine. If I force a > call to it once the form's up then there's no problem (eg a command button), > but that's not a lot of use to me either. So I know the function is fine, > but has anyone got an answer as to where I might get this to run from? > > -- > Andy Lacey > http://www.minstersystems.co.uk > > > > > ________________________________________________ > Message sent using UebiMiau 2.7.2 > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > > > > ________________________________________________ Message sent using UebiMiau 2.7.2