help with global settings

scorpio_x73

Registered User.
Local time
Today, 19:00
Joined
Jul 10, 2003
Messages
12
How do I make global variables? I have a settings table, which holds some information, which I need in every form I got. So how can I access this information from each form? I'm using usually other tables as a source of the form for the form needs, so I can't set this one as the source in these forms...

I'm building a music database and i have a table with global settings : path to winamp,path to foreign covers etc.

so i will type once in the settings form my data, but i want to use those data in many other forms
 
Rather than using global variables which seem to be occasionally unreliable, try one of the following
1. DLookup to retrieve the values.
2. Keep a form with the settings on open at all times but hidden.
3. Add the settings values to the recordsource query supplying each form (but I do not recommend this)

if you want to use globals, create a new module (not linked to a form or report) and declare the public variables there ie

Code:
Option Explicit
Public strFilePath as String
------------------------------------------------------------------------------

You can then set the variables in any code - I use the form_Load() of the opening menu/splash screen form if I use them.

hth
 
DON'T UNDERSTAND

SORRY AGAIN BUT I CAN'T UNDERSTAND HOW TO PASS THE VAR

MY DATA ARE ON THE TABLE SETTINGS !!

HOW CANI PASS THE RECORD FROM TABLE SETTINGS
TO THE VAR, AND HOW CAN I USE THE VAR IN VARIOUS FORMS

PLEASE HELP ME


THANKS IN ADVANCE
 
I have already explained how to declare a public variable in a stand alone module.

If you want the variable to be static, ie not change in the course of the application, then use

Static strFilePath as String

then for example in your opening form run this variable setting routine.

Code:
Form_Load()
Call SetVariables

in a stand alone module

Code:
Static strWinampPath as String
Static strCoverPath as string

Sub SetVariables()
dim rs as DAO.recordset
set rs=CurrentDb.OpenRecordset("tblSettings",dbOpenStatic)

strWinampPath = rs("WinampPath")
strCoverPath = rs("CoverPath")
'etc....
set rs = nothing
end sub

WinampPath is the name of the field storing the path to winamp etc
tblSettings is the name of your table holding the settings

Is this any clearer?
Please do not SHOUT if you do not get the answer you wanted - I gave you all the information previously, you just need to experiment a bit.
 
Sorry

I was not shouting

i forgot that i used caps


i'm very sorry,sorry,sorry
 

Users who are viewing this thread

Back
Top Bottom