Global Function

I'm using the following code to set the Datasheet Font on a Split
Form using AC 2007.

Private Sub Form_Open(Cancel As Integer)

    Me.DatasheetFontName = "Arial"

End Sub

I would like to use a global function so I might call the same function from 
all
my forms, but I haven't had much luck.

I tried the following:

Public Function SetDataSheetFont()

    Dim frm As Form
    Set frm = Screen.ActiveForm
    frm.DatasheetFontName = "Arial"

End Function

I get no errors but nothing happens when calling this in the OnOpen of a 
form.

Any help will be appreciated,
James


0
JamesJ
2/24/2008 10:05:31 AM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
710 Views

Similar Articles

[PageSpeed] 8

In many cases you *can* use screen.ActiveForm

However, if the focus changes, (due to a user mouse click to another form, 
then your code would not be reliable, and grab the wrong screen.

The simple solution is to *pass* the form to the code.


 Private Sub Form_Open(Cancel As Integer)

    Call SetDatasheetFont(me)

 End Sub

 Public Function SetDataSheetFont(frm as form)

    frm.DatasheetFontName = "Arial"

 End Function

-- 
Albert D. Kallal    (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com


0
Albert
2/24/2008 10:10:39 AM
Got it!

Thanks Much,
James

"Albert D. Kallal" <PleaseNOOOsPAMmkallal@msn.com> wrote in message 
news:eN8wD2sdIHA.2404@TK2MSFTNGP05.phx.gbl...
> In many cases you *can* use screen.ActiveForm
>
> However, if the focus changes, (due to a user mouse click to another form, 
> then your code would not be reliable, and grab the wrong screen.
>
> The simple solution is to *pass* the form to the code.
>
>
> Private Sub Form_Open(Cancel As Integer)
>
>    Call SetDatasheetFont(me)
>
> End Sub
>
> Public Function SetDataSheetFont(frm as form)
>
>    frm.DatasheetFontName = "Arial"
>
> End Function
>
> -- 
> Albert D. Kallal    (Access MVP)
> Edmonton, Alberta Canada
> pleaseNOOSpamKallal@msn.com
>
> 

0
JamesJ
2/24/2008 12:12:05 PM
Reply:

Similar Artilces:

error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'LPHANDLER_FUNCTION'
I wrote a VC program for service...In VC 6 it working fine...But In Visual Studio 2005 it got errorrs... My code is give below.... void CRRMService::ServiceMain() { int error; //MEMORYSTATUS memory; int result; ServiceStatus.dwServiceType = SERVICE_WIN32; ServiceStatus.dwCurrentState = SERVICE_START_PENDING; ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; ServiceStatus.dwWin32ExitCode = 0; ServiceStatus.dwServiceSpecificExitCode = 0; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint ...

Need help with function to change BackColor
I want to change the backcolor of each section of each form in the database. Acc 2003. Here is what I have finally writter. It does nothing but open each form and then close it. The line, strDo = "Forms!" & strForm & ".Detail.BackColor = 16119290" does nothing but set the value of the variable. I kept getting an error that "Object Needed" with the strDo = portion. But, this line represents the action I want to take on each form section. I know that I will need a For...Next loop to apply the change to all sections, which, what will happen i...

Data Function
How can I create a query if I have alot of dates in this format '10/23/07 12:30AM' and I want to seperate it by shift like 1st shift would be between 5:00AM to 1:30PM and just look at the time and date is irelavent. Thanks On Wed, 24 Oct 2007 08:35:04 -0700, Anthony wrote: > How can I create a query if I have alot of dates in this format '10/23/07 > 12:30AM' and I want to seperate it by shift like 1st shift would be between > 5:00AM to 1:30PM and just look at the time and date is irelavent. Thanks Look up the TimeValue function in VBA help. ?TimeValue(Now()) ...

Inconsistency between global catalog in root and global catalog in child domains
Hi, I have a very strange problem in my AD. It seems that there is an inconsistence between global catalog in the root domain and global catalog in the child domains. Global catalog on all root domain controllers are identical. Global catalog on all child domain controllers are identical. However (at least) one orphaned object exist in the global catalog on the child DC's, but not in global catalog on the root DC's. The object is not accessible through adsiedit, ldp, etc. and thus we cannot delete it. Does anybody have a good idea on how to get this object deleted. How the inco...

Sub or Function not defined
Long time XL97 user, now XL2003. I've used excel macros for years and don't remember having to do this: I have macros in my Personal.xls that I use in all my workbooks. If I get "Sub or Function not defined" error, I have to reference Personal.xls using Tools/References and pick it out. But Personal.xls is named "VBAProject(PERSONAL.XLS)" and my new workbook is named "VBAProject(Book1.xls)", so I get "Name conflicts with existing module, project, or object library". So I have to make my Personal.xls in a different project. I do this...

date functions #3
The workday formula works as noted in my previous question but I'm having trouble trying to exclude the holidays. I have a list of them but cannot get the datevalue function to convert it. Suggestions welcomed. VDan Wrote: > The workday formula works as noted in my previous question but I'm > having > trouble trying to exclude the holidays. I have a list of them but > cannot get > the datevalue function to convert it. Suggestions welcomed. Hi VDan Type the date into any cell and then format it as a number, this will give you the number to enter for holidays -- ...

Left function #2
Hi, I'm moved from Excel 2000 to 2003 and now I find that the Left an Right functions are not working correctly. They work OK if I type the in one cell at a time but if I use copy/paste it just reproduces th same result in every cell. This happens even if I use past special/values as well! Any ideas appreciate -- Message posted from http://www.ExcelForum.com Hi tools / options / calculation - ensure it is set to automatic. Cheers JulieD "dillonke >" <<dillonke.1bjvdg@excelforum-nospam.com> wrote in message news:dillonke.1bjvdg@excelforum-nospam.com... > Hi...

Catching global keystrokes
Hello. I need my program to react to some key combination no matter if the program's window is active or not. How can this be done? Depends on the details of the key combinations as to what you have to do, precisely, but a WH_GETMESSAGE hook looking for WM_KEYDOWN, WM_SYSKEYDOWN or WM_CHAR is a start. Note if the key combination is Ctrl+Alt+Del, then it will never be possible. In Vista, you will not be able to get ALL keystrokes unless you are running as administrator. See my essay on hooks on my MVP Tips site. joe On Fri, 07 Nov 2008 09:42:52 +0300, Vladimir <thamiorsinister@...

No global address list when trying to send email through excel
In excel, you can send the spreadsheet as an attachment through emai (Outlook). When I try to do this, the global address list on th server doesn't show up, therefore the person I'm trying to send it t doesn't show up. The global address list is available because I ca save the spreadsheet and create a new email and insert it as a attachment...I would like to send the spreadsheet in an email throug excel (File, Send to, mail recipient (as attachment) because it' easier...How do I change the settings to look for the GAL on th server. There was some sort of wizard that walked ...

global rule
I have a program that tags the subject line of all emails that it thinks is spam. Instead of delivering that message to the recipient I would like to create a rule to deliver it to one large spam mailbox. Is there a way to do this? I am running exchange 2003. ...

Global Function
I'm using the following code to set the Datasheet Font on a Split Form using AC 2007. Private Sub Form_Open(Cancel As Integer) Me.DatasheetFontName = "Arial" End Sub I would like to use a global function so I might call the same function from all my forms, but I haven't had much luck. I tried the following: Public Function SetDataSheetFont() Dim frm As Form Set frm = Screen.ActiveForm frm.DatasheetFontName = "Arial" End Function I get no errors but nothing happens when calling this in the OnOpen of a form. Any help will be appreciated, Ja...

Global Footer Options?
Hi there: Does anyone know if there is a global default option in Excel to ALWAY create footers with the pathname and docname for ALL worksheets? I.E. know there is the solution to create the pathname in eac footer/worksheet, but I want to set this feature as a global defaul for any worksheet I work on. Hope springs eternal : -- Message posted from http://www.ExcelForum.com Hi you can create a new template (*.xlt) file including this option. Place this in your template folder and choose this template for your new workbooks -- Regards Frank Kabel Frankfurt, Germany > Hi there: > D...

Convert Function to Sub
I have the following function which is used to extract the numeric and alpha characters from a cell. Can someone help me 'convert' this to a sub, so that, for example, with whatever range the user selects, the code will look at each cell and basically remove everything that is not either alpha or numeric? Example: 45 BJ}!12T would be converted to 45BJ12T Public Function ExtractNT(TextString As String) As String Dim x As Long Dim sChar As String ExtractNT = vbNullString For x = 1 To Len(TextString) sChar = Mid(TextString, x, 1) If sCh...

3-d array function
Hi there, I have a workbook with 50 identical worksheets. Each sheet represents different person (name of person is in a cell of every worksheet), bu all other cells are identical. I created a summary sheet where I di pick the 3 highest scores of the same cell in every worksheet (larg function). I would like to put the name of the person reaching thi score into the adjacent cell, but can't find how to do that. Any help greatfully appreciated Reine -- Message posted from http://www.ExcelForum.com Hi You may also try to download the free add-in Morefunc.xll (http://longre.free.fr/e...

shortcut to a function?
I have noticed in a few posts now that -- is used in some of the solutions to the questions asked eg =COUNT(--(ROW(1:360)>0)) My question is, what does the -- mean? See http://www.xldynamic.com/source/xld.SUMPRODUCT.html#format for a detailed explanation. Odd formula you showed, the >0 doesn't seem to do anything. -- HTH Bob Phillips "SusanR" <SusanR@discussions.microsoft.com> wrote in message news:813989D7-04BA-40C1-9DFB-BB6DD5F6AB86@microsoft.com... > I have noticed in a few posts now that -- is used in some of the solutions to > the questions aske...

Set object with a function
Hello, Can I do something like this.....? ............ Dim MyTextBox as Textbox TxtBoxNum = 3 Set MyTextBox = SetTheTextBoxFunc(TxtBoxNum) ............ Public Function SetTheTextBoxFunc(num as integer) as Textbox select case num case 1 SetTheTextBoxFunc = SLNX.Textbox1 case 2 SetTheTextBoxFunc = SLNX.Textbox2 case 3 SetTheTextBoxFunc = SLNX.Textbox3 end select end function ............... SLNX is a form with a bunch of textboxes. Thanks for any help. Cant quite figure this out. Try; Dim MyTextBox As OLEObject -- Regards Dave Hawley www.oz...

global object dependent on CWinApp global object
hi I have a global object which depends on the CWinApp global object i.e. it assumes that the CWinApp global object is created. After migrating to VS 2005, my global object is getting created before the CWinApp global object. Is there any way I can force the CWinApp object to be created first? I know one of the solution is to avoid a global object and wrap it in a fuction, however a lot of files use this object directly, so I am trying to figure out if there is another way. Regards Chimanrao Chimanrao wrote: > hi > > I have a global object which depends on the CWinApp global...

Enabling outline and level functions on a protected worksheet?
Is there a was to preserve the outline/level functions on a protected worksheet? None of the "allow all users to..." elements seem to affect this feature. When protecting a worksheet is necessary for locking certain formula cells, the outline/level functions become inoperative. I have been unable to find the answer in help screens, etc. Does anyone have the key to this mystery? More than likely, you will need to make a VBA Solution. This will require making macros to unprotect the sheet, perform the action, then reprotect the sheet. You will want to provide a custom toolbar fr...

Charttiltle as function
I have programmed a macro that makes a pivottable and a pivotdiagram. In this diagram I have a charttitle that I want to be equal to the content of one cell (D2). So if the content of the cell changes, I want the Charttitle also to change. Manually I can do this by selecting the charttitle and use the function (=D2) on the top of the excel-sheet. But this will not work when I try the recorder. Can anyone help? Are you running the macro each time the chart title changes? Barb Reinhardt "Trond" wrote: > I have programmed a macro that makes a pivottable...

prf question and global address list....
When i fire off my Oulook 2003 and manually create my profile to connect to our exchange server i get to see my GAL and my outlook address book with my contacts folder when i go to create a new message and click TO: to look at my contacts. When i start outlook 2003 using my PRF file it auto creates the profile and connects me to the server but for some reason i can only see my GAL and not my outlook address book or contacts when creating a new message. I have found this line in my PRF file under MSMail DisplayGalOnly=PT_BOOLEAN,0x6625 Im not sure if this is related but the docs say ...

VBA Function
Hello- I am somewhat of a nb so forgive my ignorance. I have developed some code that utilizes a function. The code works (i.e. the query loads), but is throwing an error. Here is the error message: "Error in procedure cmdRunQuery_Click...Error 0:" The code looks like this (this is only snippet of the code): If TypeName = "pt_query" Then results = PT(FilesName, 100) End If Here is the function: Function PT(q As String, n As Integer): On Error GoTo ProcError Dim db As DAO.Database Dim qdf As DAO.QueryDef Set db = CurrentDb() Set qdf = db.QueryDefs("1-1_de...

Date formats, culture and globalization
Hi, ASP.NET 3.5 We are creating a 3-tier ASP.NET Web Application that needs just to understand dates as UK shortdate format (dd/MM/yyyy). It will only be used in the UK on intranet. I often come across web server and client machine that are incorrectly set up so I want to protect the app from these incorrectly set up hosts. I understand the safe date formats for passing through to the database. SQLParameters pass through a non-ambiguous format and also that 'yyyyMMdd' is also a safe format. So ignore the database side of things - I get that. At the moment all the bou...

Rule based on Global Address list?
Is there a way to create a rule in Outlook 2000 that says: route all mail from anyone not in my Global Address List to my Junk E-mail folder? ...

mail list function
I have been told that I can enter names, addresses, emails and other customer details into an excel workbook and then manipulate it to create an address lable list in word or a contact list for outlook express. I have entered all my info but am having difficulty proceeding. I am new to excel HELP! thank you For help on Word mail merge using Excel as the data source. http://www.mvps.org/dmcritchie/excel/mailmerg.htm http://www.mvps.org/word/FAQs/MailMerge/CreateAMailMerge.htm http://www.mvps.org/word/FAQs/MailMerge/CreateADataSource.htm For the Contact List............... If all yo...

Global calendar entries
Is there any way of adding calendar entries (such as bank holiday information) globally into exchange so that all users see it in their Outlook calendars? I'd like to avoid users having to import it into their calendars manually if possible. Many thanks in advance (and apologies if this question has been asked before). ...