By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,092 Members | 1,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,092 IT Pros & Developers. It's quick & easy.

access vba function get form caption

P: n/a
hi, to all
i was wondering if some one got this problem before and if he had any
solution
i got a query:

SELECT MSysObjects.Name, MSysObjects.Type, GETFRMCAPTION([Name]) AS
Expr1
FROM MSysObjects
WHERE (((MSysObjects.Type)=-32768));

and this function to get form caption

Public Function GETFRMCAPTION(FRMNM As String) As String

test = "Forms" & "!" & FRMNM & "." & "Caption"
GETFRMCAPTION = Eval("Forms" & "!" & FRMNM & "." & "Caption")

End Function

but it will not work

the final result i want to get the form caption in the the field expr1
in the query to be added later in the security form of the application

i will be more than thankfull if any one could help me in this problem

many thanks and regards in advance
Nov 12 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Please recall that the Forms collection includes only those forms which are
open at the time that the code is run.
Therefore, unless you first open all the forms, this code will not return
their captions.
I don't think that the .Caption property is available without opening the
forms, anyhow.

I'm not sure what you want this information for.
Although far from perfect, the built-in security available for Access is
most certainly superior to most anything you can build yourself.

HTH
- Turtle

"SELIM ZAIRI" <SE********@HOTMAIL.COM> wrote in message
news:2d*************************@posting.google.co m...
hi, to all
i was wondering if some one got this problem before and if he had any
solution
i got a query:

SELECT MSysObjects.Name, MSysObjects.Type, GETFRMCAPTION([Name]) AS
Expr1
FROM MSysObjects
WHERE (((MSysObjects.Type)=-32768));

and this function to get form caption

Public Function GETFRMCAPTION(FRMNM As String) As String

test = "Forms" & "!" & FRMNM & "." & "Caption"
GETFRMCAPTION = Eval("Forms" & "!" & FRMNM & "." & "Caption")

End Function

but it will not work

the final result i want to get the form caption in the the field expr1
in the query to be added later in the security form of the application

i will be more than thankfull if any one could help me in this problem

many thanks and regards in advance

Nov 12 '05 #2

P: n/a
SELIM ZAIRI wrote:
hi, to all
i was wondering if some one got this problem before and if he had any
solution
i got a query:

SELECT MSysObjects.Name, MSysObjects.Type, GETFRMCAPTION([Name]) AS
Expr1
FROM MSysObjects
WHERE (((MSysObjects.Type)=-32768));

and this function to get form caption

Public Function GETFRMCAPTION(FRMNM As String) As String

test = "Forms" & "!" & FRMNM & "." & "Caption"
GETFRMCAPTION = Eval("Forms" & "!" & FRMNM & "." & "Caption")

End Function

but it will not work

the final result i want to get the form caption in the the field expr1
in the query to be added later in the security form of the application

i will be more than thankfull if any one could help me in this problem

many thanks and regards in advance


The form has to be open to get it's caption.

Try:
Public Function GETFRMCAPTION(FRMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign
GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
Docmd.Close FRMNM, acSaveNo
End Function

Bit messy when running.
--
But why is the Rum gone?
Nov 12 '05 #3

P: n/a
"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.easyne t.net...

The form has to be open to get it's caption.

Try:
Public Function GETFRMCAPTION(FRMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign
GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
Docmd.Close FRMNM, acSaveNo
End Function

Bit messy when running.


It'll be a little less messy if you open each form as hidden:

Public Function GETFRMCAPTION(FRMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign, , , , acHidden
GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
Docmd.Close FRMNM, acSaveNo
End Function
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)

Nov 12 '05 #4

P: n/a
Douglas J. Steele wrote:
"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.easyne t.net...
The form has to be open to get it's caption.

Try:
Public Function GETFRMCAPTION(FRMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign
GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
Docmd.Close FRMNM, acSaveNo
End Function

Bit messy when running.

It'll be a little less messy if you open each form as hidden:

Public Function GETFRMCAPTION(FRMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign, , , , acHidden
GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
Docmd.Close FRMNM, acSaveNo
End Function

Well spotted, now pay attention as next time I will test you without
warning :-)

And of course the close command should be:
Docmd.Close acForm, FRMNM, acSaveNo

--
But why is the Rum gone?
Nov 12 '05 #5

P: n/a
rkc

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:g_********************@news04.bloor.is.net.ca ble.rogers.com...
"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.easyne t.net...

The form has to be open to get it's caption.

Try:
Public Function GETFRMCAPTION(FRMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign
GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
Docmd.Close FRMNM, acSaveNo
End Function


This function is in dire need of a "air code" warning.

GETFRMCAPTION = Forms(FRMNM).Caption
DoCmd.Close acForm, FRMNM, acSaveNo


Nov 12 '05 #6

P: n/a
"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in message
news:41********************@twister.nyroc.rr.com.. .

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:g_********************@news04.bloor.is.net.ca ble.rogers.com...
"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.easyne t.net...

The form has to be open to get it's caption.

Try:
Public Function GETFRMCAPTION(FRMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign
GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
Docmd.Close FRMNM, acSaveNo
End Function


This function is in dire need of a "air code" warning.

GETFRMCAPTION = Forms(FRMNM).Caption
DoCmd.Close acForm, FRMNM, acSaveNo


Ironically, I copied my change to the OpenForm statement from a tested
function. I just didn't bother looking at the rest of the code!
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)


Nov 12 '05 #7

P: n/a
"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in
news:41********************@twister.nyroc.rr.com:
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in
message
news:g_********************@news04.bloor.is.net.ca ble.rogers.com...
"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.easyne t.net...
>
> The form has to be open to get it's caption.
>
> Try:
> Public Function GETFRMCAPTION(FRMNM As String) As String
> DoCmd.OpenForm FRMNM, acDesign
> GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
> Docmd.Close FRMNM, acSaveNo
> End Function


This function is in dire need of a "air code" warning.

GETFRMCAPTION = Forms(FRMNM).Caption
DoCmd.Close acForm, FRMNM, acSaveNo


Not only that, but it assumes the form is not open when it runs. I'd
be pretty annoyed if I had the form open and it suddenly
disappeared.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #8

P: n/a
David W. Fenton wrote:
"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in
news:41********************@twister.nyroc.rr.com:

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in
message
news:g_********************@news04.bloor.is.net. cable.rogers.com...
"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.eas ynet.net...

The form has to be open to get it's caption.

Try:
Public Function GETFRMCAPTION(FRMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign
GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
Docmd.Close FRMNM, acSaveNo
End Function


This function is in dire need of a "air code" warning.

GETFRMCAPTION = Forms(FRMNM).Caption
DoCmd.Close acForm, FRMNM, acSaveNo

Not only that, but it assumes the form is not open when it runs. I'd
be pretty annoyed if I had the form open and it suddenly
disappeared.

Oh well, I'm sorry I didn't spend at least a couple of hours testing the
function under all possible circumstances to answer a fecking newsgroup
post. Sheesh, I dunno why I bother sometimes.

--
But why is the Rum gone?
Nov 12 '05 #9

P: n/a
rkc

"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.easyne t.net...
David W. Fenton wrote:
"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in
news:41********************@twister.nyroc.rr.com:

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in
message
news:g_********************@news04.bloor.is.net. cable.rogers.com...

"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.eas ynet.net...

>The form has to be open to get it's caption.
>
>Try:
>Public Function GETFRMCAPTION(FRMNM As String) As String
> DoCmd.OpenForm FRMNM, acDesign
> GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
> Docmd.Close FRMNM, acSaveNo
>End Function

This function is in dire need of a "air code" warning.

GETFRMCAPTION = Forms(FRMNM).Caption
DoCmd.Close acForm, FRMNM, acSaveNo

Not only that, but it assumes the form is not open when it runs. I'd
be pretty annoyed if I had the form open and it suddenly
disappeared.

Oh well, I'm sorry I didn't spend at least a couple of hours testing the
function under all possible circumstances to answer a fecking newsgroup
post. Sheesh, I dunno why I bother sometimes.


Was so touchy?

I only replied after an expert corrected an expert and the function
still had problems even running.

DWF's point is a real killer though, isn't it?



Nov 12 '05 #10

P: n/a
"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in
news:H6********************@twister.nyroc.rr.com:

"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.easyne t.net...
David W. Fenton wrote:
> "rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in
> news:41********************@twister.nyroc.rr.com:
>
>
>>"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote
>>in message
>>news:g_F2c.184031$Qg7.63431 @news04.bloor.is.net.cable.rogers.com >>...
>>
>>>"Trevor Best" <nospam@localhost> wrote in message
>>>news:40***********************@auth.uk.news.eas ynet.net...
>>>
>>>>The form has to be open to get it's caption.
>>>>
>>>>Try:
>>>>Public Function GETFRMCAPTION(FRMNM As String) As String
>>>> DoCmd.OpenForm FRMNM, acDesign
>>>> GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
>>>> Docmd.Close FRMNM, acSaveNo
>>>>End Function
>>
>>This function is in dire need of a "air code" warning.
>>
>>GETFRMCAPTION = Forms(FRMNM).Caption
>>DoCmd.Close acForm, FRMNM, acSaveNo
>
>
> Not only that, but it assumes the form is not open when it
> runs. I'd be pretty annoyed if I had the form open and it
> suddenly disappeared.
>

Oh well, I'm sorry I didn't spend at least a couple of hours
testing the function under all possible circumstances to answer a
fecking newsgroup post. Sheesh, I dunno why I bother sometimes.


Was so touchy?

I only replied after an expert corrected an expert and the
function still had problems even running.

DWF's point is a real killer though, isn't it?


I don't know if it's a killer or not, but it does suggest that
perhaps the proper way to accomplish this is through the Documents
collection (assuming A97) or via whatever the name of the new
collection is in A2K+.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #11

P: n/a
David W. Fenton wrote:
"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in
news:H6********************@twister.nyroc.rr.com:

"Trevor Best" <nospam@localhost> wrote in message
news:40***********************@auth.uk.news.easy net.net...
David W. Fenton wrote:

"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in
news:41********************@twister.nyroc.rr.c om:

>"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote
>in message
>news:g_F2c.184031$Qg7.63431
@news04.bloor.is.net.cable.rogers.com
...
>
>
>>"Trevor Best" <nospam@localhost> wrote in message
>>news:40***********************@auth.uk.news. easynet.net...
>>
>>
>>>The form has to be open to get it's caption.
>>>
>>>Try:
>>>Public Function GETFRMCAPTION(FRMNM As String) As String
>>> DoCmd.OpenForm FRMNM, acDesign
>>> GETFRMCAPTION = Forms(GETFRMCAPTION).Caption
>>> Docmd.Close FRMNM, acSaveNo
>>>End Function
>
>This function is in dire need of a "air code" warning.
>
>GETFRMCAPTION = Forms(FRMNM).Caption
>DoCmd.Close acForm, FRMNM, acSaveNo
Not only that, but it assumes the form is not open when it
runs. I'd be pretty annoyed if I had the form open and it
suddenly disappeared.
Oh well, I'm sorry I didn't spend at least a couple of hours
testing the function under all possible circumstances to answer a
fecking newsgroup post. Sheesh, I dunno why I bother sometimes.


Was so touchy?

I only replied after an expert corrected an expert and the
function still had problems even running.

DWF's point is a real killer though, isn't it?

I don't know if it's a killer or not, but it does suggest that
perhaps the proper way to accomplish this is through the Documents
collection (assuming A97) or via whatever the name of the new
collection is in A2K+.

Same as 97 in A2K+ and yes you're right about using the collection and
not undocumented MSys tables and had thought about that at the time but
I wasn't in the mood for picking at the OP's methods :-).

--
But why is the Rum gone?
Nov 12 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.