473,586 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

access vba function get form caption

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.Nam e, MSysObjects.Typ e, GETFRMCAPTION([Name]) AS
Expr1
FROM MSysObjects
WHERE (((MSysObjects. Type)=-32768));

and this function to get form caption

Public Function GETFRMCAPTION(F RMNM 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
11 5947
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********@HOT MAIL.COM> wrote in message
news:2d******** *************** **@posting.goog le.com...
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.Nam e, MSysObjects.Typ e, GETFRMCAPTION([Name]) AS
Expr1
FROM MSysObjects
WHERE (((MSysObjects. Type)=-32768));

and this function to get form caption

Public Function GETFRMCAPTION(F RMNM 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
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.Nam e, MSysObjects.Typ e, GETFRMCAPTION([Name]) AS
Expr1
FROM MSysObjects
WHERE (((MSysObjects. Type)=-32768));

and this function to get form caption

Public Function GETFRMCAPTION(F RMNM 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(F RMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign
GETFRMCAPTION = Forms(GETFRMCAP TION).Caption
Docmd.Close FRMNM, acSaveNo
End Function

Bit messy when running.
--
But why is the Rum gone?
Nov 12 '05 #3
"Trevor Best" <nospam@localho st> wrote in message
news:40******** *************** @auth.uk.news.e asynet.net...

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

Try:
Public Function GETFRMCAPTION(F RMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign
GETFRMCAPTION = Forms(GETFRMCAP TION).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(F RMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign, , , , acHidden
GETFRMCAPTION = Forms(GETFRMCAP TION).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
Douglas J. Steele wrote:
"Trevor Best" <nospam@localho st> wrote in message
news:40******** *************** @auth.uk.news.e asynet.net...
The form has to be open to get it's caption.

Try:
Public Function GETFRMCAPTION(F RMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign
GETFRMCAPTION = Forms(GETFRMCAP TION).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(F RMNM As String) As String
DoCmd.OpenForm FRMNM, acDesign, , , , acHidden
GETFRMCAPTION = Forms(GETFRMCAP TION).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
rkc

"Douglas J. Steele" <NOSPAM_djsteel e@NOSPAM_canada .com> wrote in message
news:g_******** ************@ne ws04.bloor.is.n et.cable.rogers .com...
"Trevor Best" <nospam@localho st> wrote in message
news:40******** *************** @auth.uk.news.e asynet.net...

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

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


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

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


Nov 12 '05 #6
"rkc" <rk*@yabba.dabb a.do.rochester. rr.bomb> wrote in message
news:41******** ************@tw ister.nyroc.rr. com...

"Douglas J. Steele" <NOSPAM_djsteel e@NOSPAM_canada .com> wrote in message
news:g_******** ************@ne ws04.bloor.is.n et.cable.rogers .com...
"Trevor Best" <nospam@localho st> wrote in message
news:40******** *************** @auth.uk.news.e asynet.net...

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

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


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

GETFRMCAPTION = Forms(FRMNM).Ca ption
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
"rkc" <rk*@yabba.dabb a.do.rochester. rr.bomb> wrote in
news:41******** ************@tw ister.nyroc.rr. com:
"Douglas J. Steele" <NOSPAM_djsteel e@NOSPAM_canada .com> wrote in
message
news:g_******** ************@ne ws04.bloor.is.n et.cable.rogers .com...
"Trevor Best" <nospam@localho st> wrote in message
news:40******** *************** @auth.uk.news.e asynet.net...
>
> The form has to be open to get it's caption.
>
> Try:
> Public Function GETFRMCAPTION(F RMNM As String) As String
> DoCmd.OpenForm FRMNM, acDesign
> GETFRMCAPTION = Forms(GETFRMCAP TION).Caption
> Docmd.Close FRMNM, acSaveNo
> End Function


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

GETFRMCAPTION = Forms(FRMNM).Ca ption
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
David W. Fenton wrote:
"rkc" <rk*@yabba.dabb a.do.rochester. rr.bomb> wrote in
news:41******** ************@tw ister.nyroc.rr. com:

"Douglas J. Steele" <NOSPAM_djsteel e@NOSPAM_canada .com> wrote in
message
news:g_****** **************@ news04.bloor.is .net.cable.roge rs.com...
"Trevor Best" <nospam@localho st> wrote in message
news:40***** *************** ***@auth.uk.new s.easynet.net.. .

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

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


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

GETFRMCAPTI ON = Forms(FRMNM).Ca ption
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
rkc

"Trevor Best" <nospam@localho st> wrote in message
news:40******** *************** @auth.uk.news.e asynet.net...
David W. Fenton wrote:
"rkc" <rk*@yabba.dabb a.do.rochester. rr.bomb> wrote in
news:41******** ************@tw ister.nyroc.rr. com:

"Douglas J. Steele" <NOSPAM_djsteel e@NOSPAM_canada .com> wrote in
message
news:g_****** **************@ news04.bloor.is .net.cable.roge rs.com...

"Trevor Best" <nospam@localho st> wrote in message
news:40***** *************** ***@auth.uk.new s.easynet.net.. .

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

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

GETFRMCAPTI ON = Forms(FRMNM).Ca ption
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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
7420
by: MLH | last post by:
I've followed the instructions found on Microsoft's site... http://support.microsoft.com/default.aspx?scid=kb;en-us;149119&Product=acc97 Here are those instructions... To play and record sounds, follow these steps: Create the following new table in Design view: Table: Messages ----------------------- Field Name: Message Data Type:...
6
4730
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
7
8841
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and...
11
6579
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am...
1
5904
by: Ray Holtz | last post by:
I have a database in Access 2003 (Access2000 file format). There are two tables that are being used: Employees and Items. It is linked by the Employee field so that one employee can have many items. I have a VB6 application that is tied into this database using an ADODB.Connection and uses two ADODB.Recordsets: rsEmployees and rsItems. I...
42
11498
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
5
2673
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp The Joy of Interoperability Sometimes a revolution in programming forces you to abandon all that's come before. To take an extreme example, suppose you have been writing Visual Basic applications for years now. If you're like many developers,...
29
15424
by: Hutch | last post by:
!!!!FIRST!!! The fallowing code gets placed into a module that has to be called "SetAccessWindow" Option Compare Database Option Explicit Global Const SW_HIDE = 0 Global Const SW_SHOWNORMAL = 1 Global Const SW_SHOWMINIMIZED = 2 Global Const SW_SHOWMAXIMIZED = 3
7
2114
by: dkohel | last post by:
I have a form that returns 100 items. All of the items have have a different value in their Category field. EXAMPLE: ---------------- A B C How can I change the value of the caption in the field label on the
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.