Constants

E

Emma Hope

Hi All,

I have a form called frmWeekly on the VBA window for this form, i have a Sub
which sends an email, the code pulls of certain information from the forms
such as receipient txtTo, subject txtSubject etc.

I have a lot of information such as 'Path' information that i use repeatedly
through this code and other subs on this and other forms.

I would like to declare the path as a constant, i have opened a new module
and added: Public Const strPathReports As String =
"Y:\Shared\Tsoi01\TEAMDATA\Onstream Management Information\Reports\Current
Year\Weekly\"

However when i use strPathReports in my code for my sub on the form it comes
back 'empty'.

Why doesn't this work and is there any way around it, other than typing my
constant at the top of every forms code page (Microsoft Office Access Class
Objects) which seems to defeat the object.

Thanks for your help!
Emma
 
D

Douglas J. Steele

Glad you got it working, but the fact that it was a spelling problem implies
that you haven't told Access to require that all variables be declared.

The line

Option Explicit

should be at the top of every module.

Once it's there, you'd have got a "Undefined Variable" error, which might
have saved you a fair bit of time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top