Are there functions/Or Events that are called automatically when the database file first opens and When it closes?

All,
I'm assuming its "Public Function init_something()" but I can't seem to find a reference to the correct syntax.  I'm using Access 2007.

Basically what I'm trying to do is initialize a list of global variables and I can't seem to figure out how to do it.

	Option Compare Database

	Public VariableName As String
	
	'Call Init - Will throw an error
	'VariableName = "Hello World" - Will throw an error

	Option Explicit

		Public Function Init()
	        	VariableName = "Hello World"
		End Function

		Private Sub btName_Click()
     			MsgBox (VariableName)
		End Sub

' this is the only way that I can seem to get this to work and I'm sure that there is a better way of doing it.

Private Sub test_Click()

     If VariableName = "" Then
         Call Init
     End If

     MsgBox (VariableName)
     VariableName = "Some New Value"
End Sub

Also are all modules initiated when the database first opens?
Is there an order to when they are loaded?

Thanks in advance. - CES
0
CES
3/21/2007 9:27:51 PM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
576 Views

Similar Articles

[PageSpeed] 28

All macros named AutoExec.


"CES" <none@none.com> wrote in message
news:uyNm$%23$aHHA.208@TK2MSFTNGP05.phx.gbl...
> All,
> I'm assuming its "Public Function init_something()" but I can't seem to
find a reference to the correct syntax.  I'm using Access 2007.
>
> Basically what I'm trying to do is initialize a list of global variables
and I can't seem to figure out how to do it.
>
> Option Compare Database
>
> Public VariableName As String
>
> 'Call Init - Will throw an error
> 'VariableName = "Hello World" - Will throw an error
>
> Option Explicit
>
> Public Function Init()
>         VariableName = "Hello World"
> End Function
>
> Private Sub btName_Click()
>      MsgBox (VariableName)
> End Sub
>
> ' this is the only way that I can seem to get this to work and I'm sure
that there is a better way of doing it.
>
> Private Sub test_Click()
>
>      If VariableName = "" Then
>          Call Init
>      End If
>
>      MsgBox (VariableName)
>      VariableName = "Some New Value"
> End Sub
>
> Also are all modules initiated when the database first opens?
> Is there an order to when they are loaded?
>
> Thanks in advance. - CES


0
Powderfinger
3/21/2007 11:03:54 PM
On Wed, 21 Mar 2007 17:27:51 -0400, CES <none@none.com> wrote:

>Also are all modules initiated when the database first opens?

No: only when a Sub or Function in the module is called. The modules just sit
there waiting to serve.

I'd suggest having a Form open automatically - use Tools... Startup and select
a form name. You can do your initialization code in that form's Open event.
Disable its Close button but provide a button to make it invisible so the user
doesn't inappropriately close and reopen it.

             John W. Vinson [MVP]
0
John
3/21/2007 11:18:53 PM
Reply:

Similar Artilces:

ROUND Function with other function
Hi, I have this formula: =IF(R8>0,CONCATENATE("+",R8),R8) and the results shows me for example: +11.6 but what I really want t show is +12. I've been trying to put the "Round" function at a few places in th formula but it doesn't work. The closest I got was with this formula: =ROUND(IF(R8>0,CONCATENATE("+",R8),R8),0) where it showed me 12, without the "+" sign before.... Can anyone help me ? Thank -- Outapi ----------------------------------------------------------------------- Outapin's Profile: http://www.excelforum.com/member...

Returning a range from an inner function
I have a range of data, which has had the DOLLAR() function performed on it. I would like to get the total of this range using the SUM() function. doing SUM(F1:F4) will not work, so I need to convert the data into values that will work. The VALUE() function is perfect for converting the data into values that will work for SUM(), but the formula SUM(VALUE(F1:F4)) does not work because VALUE() will not accept a range as a parameter (and also does not return a range). I need to perform the VALUE() function on each cell before submitting it to SUM(). There must be some way to do this, cons...

ENTOURAGE cannot access database
MAC 2006 10.4.11 I hope you can help. I tried accessing my entourage only to find message saying 'entourage could not access my database'... I read pages on www.entourage.mvps.org and reduced the free disk space among other things. Hours later (and not really knowing the damage/help that I had done) I clicked on entourage to find that it would open but by setting up a new account....therefore without all the hundreds of work emails/contacts that I desperately need. I have what I think is the old database but remember reading message saying that re build is unlik...

JustifyString function problem
Hi, I'm using the "JustifyString" function (from Stephan Lebans) to right justify three columns in a ListBox. Two of them are working fine ... one's a simple number (long integer) and the other's currency. The third causes an Access 2003 crash! That third column is a long integer which is a link to the autonumber field in another table. Both tables are in the query as I need columns from both tables in the ListBox. If I change the JustifyString to reference the autonumber field in the other table, I still get an Access crash. I didn't review the Access er...

.NET Runtime 2.0 Error
Hi there, Never had a problem with this before, so I'm guessing it must be one of the latest Windows Updates that has done it... We are using Business Contacts Manager on our SBS2003 server..., and have a single central shared database... When I run up Outlook and select Business Tools, Share Database, then add the new users, by ticking the boxes, it fails... This is the error reported in the Event Viewer... Event Type: Information Event Source: .NET Runtime 2.0 Error Reporting Event Category: None Event ID: 5001 Date: 02/10/2006 Time: 17:37:28 User: N/A Computer: WARNESLOGIN1 Desc...

ANN: Database Workbench 4.0.2 released
Ladies, gentlemen, Upscene Productions is proud to announce the next version of the popular multi-DBMS development tool: " Database Workbench 4.0.2 Pro " Version 4 introduced full Unicode support, 4.0.2 fixes some issues found in that initial release, like ODBC connectivity issues, BLOBs taking too much memory, the ability to specify file encoding when saving SQL & Scripts and several other errors. For a full list of fixes in version 4.0.2 and previous versions, see: http://www.upscene.com/go/?go=tracker&v=4.0.2&id=1 http://www.upscene.com/go/?go=tracker...

An unhandled exception occurs when call ::AfxBeginThread()
hi, I am writing a multi-thread procedure now, and an unhandled exception occurs when i call ::AfxBeginThread() to dynamically create a thread in the main thread. I have no idea to solve this problem, so come here for your help. Thank you very much for any suggestion or help, and i really appreciate it. Because there are several relative threads which are needed to be dynamically created, i define a abstract class CThreadBase which is derived from CWinThread as the base class of those thread classes. The following is defination of those thread classes: // ----------------- ThreadBase.h...

Subform help for a case management database
Hi I have a case management database where there is one main form and a subform. The subform is a tab control (with 5 tabs). Within each tab control is a subform which also consists of a tab control. The key for the database is the StudentID. What I want to do is to be able to see all the subforms for a particular student. So if I choose to see all the pertinent information collected for Student01 (aka John Smith), when I navigate through the subform, only John's information will appear. The Subform has a tabcontrol based on themes. For each theme, the tabcontrol ...

attachments turning to dat files
Help! all of my attachements to outlook emails are received as dat files and are unreadable. Does anyone have a solution for this? Change your message format from Rich Text to HTML or Plain Text. You can do this in Tools-> Options-> tab Mail Format -- Roady [MVP] www.sparnaaij.net Microsoft Office and Microsoft Office related News Also Outlook FAQ, How To's, Downloads and more... Tips of the month: -Create your own fully customized Toolbar -Creating a Classic View in Outlook 2003 Subscribe to the newsletter to receive news and tips & tricks in your mailbox! www.sparnaaij.ne...

automating functions
I am a complete novice at CRM 1.2, but want to be able to create, for example, a workflow process that will monitor the CSR's and the queues and automatically assign a new case to the least busy CSR. Any input would be appreciated. Thanks in advance Jim Please tell me what I would have to do and with what tools in order to create such a workflow process. "jmb" wrote: > I am a complete novice at CRM 1.2, but want to be able to create, for > example, a workflow process that will monitor the CSR's and the queues and > automatically assign a new case to the lea...

Parse a path for a file name in Access
Hi All, How do I parse a file path in Access for return the file name? Example c:\somefolder\somefolder\somefolder\somefolder\somefolder\somefolder\somefolder\someFile.xls I want to query a table with this value and just return 'someFile.xls" no matter how long or short the path is. I can do this in SQL Server, but i am new to Access SQL and I can not figure it quite out. Any help is always appreciated. Cheers, ~ck On Wed, 06 Feb 2008 20:23:34 GMT, CK wrote: > Hi All, > How do I parse a file path in Access for return the file name? > Example > c:\somefolder\somefol...

Returning a CHAR[] from a function
I have the following function that returns the path of where the program was run from. However I cant seem to return the butter as a CHAR. The code works if I use it in a procedure but not where I need to return the variable CHAR buffer. char CAutoRunDlg::GetProgramPath(void) { char buffer[_MAX_PATH]; //declares maimum path //opens window maximized //_getcwd(,)gets the current working directory // #include <direct.h> //needed for current working directory /* Get the current working directory: */ if( _getcwd( buffer, _MAX_PATH ) == NULL ) perror( "_getcwd error" )...

How to import addresses and emails from FILE
I just reformatted my HDD and switched from W2K to XP Pro. I backed up my files and reinstalled Office 2000. Now, I find that the way that you're supposed to save your address book, emails, and such is to export them to a database file and then import them to the new installation. I'm assuming that the information is saved in one or more of the files that I copied en mass prior to the reformat. Can someone tell me which files contain my user-data and how to get them back? Getting my Rules back would be nice too. I'm fairly proficient with DBMS so if there is a CSV fil...

Routing and Remote Access service affect the files sharing??
Dear all friends, My company use windows small business 2003 to a files server, now I got a problem with my server. Everytime I restart the sever, all the user cannot connect to the server(Including use ping,\\192.168.xxx.xxx or use remote desktop) . After I restart the Routing and Remote Access service and stop the service, then the server will being normal.Even I alreday set the default to STOP. But everytime I restart my server, I need to start the service and stop. Anyone know what happen to my server? My server is a domain controller, but all user PC have not join the dom...

Turning Off Error Reporting using API Functions and VB
We want to automatically turn off the error reporting options using Windows API functions for the following functions area Click on Start, Settings, Control Panel, System, the Advanced tab and Error Reporting (at the bottom of the screen), which launches the Error Reporting screen. Another way to get to that screen: Open My Computer, right-click on Properties, click on Advanced tab and Error Reporting. Any assistance would be welcome. It's not a program's call. It's the user's decision. --=20 -------------------------------------------------------------------------= --...

When I double click on a xls or doc file
When I double click on an Excel file or word file it seems that it is trying to open twice. I get this message: A document with the name "filename" is already open. You cannot open two documents with the same name, even if the documents are in different folders. To open the second document, either close the document that is currently open, or rename one of the documents I even tried to just select it and hit enter. It will work if I am in word or excel and use the file open command. any clues!! ... Try this JJ Tools>Options>General uncheck "Ignore other Applica...

Can't open Documents
When I try and open documents on my Office 2004 for Mac I get an error message, saying that the file can't be opened because it is already opened or some other program is trying to open it. I know that it is not open anywhere else and I have the same problem with Excel, Word, and Powerpoint documents that I received from co- workers in Entourage. The files I received where all created on PC systems. Any thoughts??? OK, we need to do a little differential diagnosis here because this one is going to be complex. First, please work your way patiently through the trouble-shooting tips her...

LDAP Operations Event ID: 8270
The event log on my Exchange 2003 SP1 server has started logging No Such Object error messages for 6 objects. These 6 objects are referenced by SID and or GUID numbers, but I do not know how to find these objects. There are 6 Event ID 8270 error messages logged every 30 minutes. The missing objects are for a newly upgrade NT4 domain that was joined to the 2003 AD forest and 2003 forest Exchange server. I suspect these objects are pointing to a domain controller that was not upgraded from NT4 to 2003, but the computer account was showing up as a member of the Domain Controllers. I d...

Complex functions
Hi All, Suppose you have a very complex and long function that is also subject to a condition, then you will/can have something like: =if(condition(complex function), complex function, other complex function) It can have more lines in the formula bar, so readability below 0 Kelvin. Is there a way to 'name' a function? =If(condition(myfunc = complex function), myfunc, other complex function) With kind regards, JP Yes you can put a formula into an Excel Name (the same as you can give a range an Excel Name. Very powerful it can be too. Do a Google fo...

Long process crashes in VPC image with NT error Event ID'1000'
I have a Virtual Server running a test environment and am image with SQL 2005 and GP 9.0 (same issue in gp10) and GP crashes with an Event ID of 1000 in the NT log file when running a MRP process (third party). When I run a MRP process the first time everything is fine. I do notice that the SQL server process in task manager is sucking up more memory and not releasing it. The second time I run it it gets about 3/4 of the way through and then it crashes. If I run the MRP process on a bigger company it crashes the first time through. If I run this process on a local machine the SQL i...

Match Function
Hi, I have put together a spreadsheet to find codes, states, descriptions. It finds the data by dates. Columns are: Dates, Codes, States, Descriptions If I put in a date it matches the code, state and description. My problem is that if I have 2 dates that are the same it will only match the first date it can find. What kind of formula do I need so that it will output the second or third date data. Thanks for your help. If you need a copy of the spreadsheet please let me know. How many rows of data do you have? -- Biff Microsoft Excel MVP "Melanie" <Melanie@discussio...

If Function Function
okay. So I am trying to workout a formula to compute a commision earning. Basically, if X amount of new business is made, then X*Y (corresponding Commision rate percentage), but if new business =<X, then X*Y (Commision rate percentage that is true). Problem is, it's super confusing...anyone have any suggestions? See if this helps: http://mcgimpsey.com/excel/variablerate.html -- Biff Microsoft Excel MVP "aetejada" <aetejada@discussions.microsoft.com> wrote in message news:AA4E55F7-9435-4BB6-837A-416A59BB72A0@microsoft.com... > okay. So I am...

Database Daemon would not run in background
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: intel Hi, I just installed Office 2008 with all the latest updates and have this sight problem; it seems that the Microsoft Database Daemon, which previous stays running in the background and alerts me of events etc, no longer gets installed in login items. I tried putting it there myself, but as soon as I startup any office program, the login item gets removed (by office?) I tried removing all preferences files, created a new profile, tried in different account etc. It's the same-Microsoft Database Daemon only starts up ...

Importing a Text File
I have a standard TAB delimited text file that I need to import into a worksheet. This file is generated by another application and I simply want to load the data into Excel so our users can manipulate it themselves, however they want to look at it. When I just do a Data->Import External Data into a totally blank worksheet, everything works fine. However, when I try to do a Data->Import External Data into the second row of a new worksheet (the first row contains a list of column headings) created from a template I created (the template simply puts some data validation on a fe...

Event 1025 Error 1102 MsExchangeIS Mailbox
Can anyone shed some light on the problem below? I see there was a similar problem (and post-service pack fix) for Exchange 2000 (http://support.microsoft.com/? id=327997), but I haven't found anything for Exchange 2003. Thanks!!! Source: MsExchangeIS Mailbox Category: General Type: Warning Event ID: 1025 Description: An error occured on database "<Storage Group\Mail Store>". Function name or description of problem: Restrict/SetSearchCriteria Error -1102 - Warning: Fail to apply search optimization to folder (FID-xxxx). Retrying without optimization. Any...