![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Am trying to use the following in declarations section of form module. Of course, it won't compile. What's the best way to set my constants inside the If-Then. I need a work-a-round. Can I set Form module constants outside the form module's uppermos declarations section? Option Compare Database Option Explicit Const SmallEnvWt As Double = 0.2059 Const LargEnvWt As Double = 0.625 Const PaperWeight As Double = 0.1666667 If Now < #5/11/2009# Then Const FirstClassStamp As Double = 0.42 Const FirstClassOn9x12 As Double = 0.83 Const OneOunceJumpRate As Double = 0.17 Const Certified3811 As Double = 2.7 Const RetRcpt3800 As Double = 2.2 Const NonMachinableSurcharge As Double = 0.2 Else Const FirstClassStamp As Double = 0.44 Const FirstClassOn9x12 As Double = 0.88 Const OneOunceJumpRate As Double = 0.17 Const Certified3811 As Double = 2.8 Const RetRcpt3800 As Double = 2.3 Const NonMachinableSurcharge As Double = 0.2 End If |
#3
| |||
| |||
|
|
Am trying to use the following in declarations section of form module. Of course, it won't compile. What's the best way to set my constants inside the If-Then. I need a work-a-round. Can I set Form module constants outside the form module's uppermos declarations section? Option Compare Database Option Explicit Const SmallEnvWt As Double = 0.2059 Const LargEnvWt As Double = 0.625 Const PaperWeight As Double = 0.1666667 If Now < #5/11/2009# Then Const FirstClassStamp As Double = 0.42 Const FirstClassOn9x12 As Double = 0.83 Const OneOunceJumpRate As Double = 0.17 Const Certified3811 As Double = 2.7 Const RetRcpt3800 As Double = 2.2 Const NonMachinableSurcharge As Double = 0.2 Else Const FirstClassStamp As Double = 0.44 Const FirstClassOn9x12 As Double = 0.88 Const OneOunceJumpRate As Double = 0.17 Const Certified3811 As Double = 2.8 Const RetRcpt3800 As Double = 2.3 Const NonMachinableSurcharge As Double = 0.2 End If |
#4
| |||
| |||
|
|
OTOH, Lyle has been known to come up with innovative ways of doing things that many folks think is impossible. |
#5
| |||
| |||
|
|
On Apr 12, 10:19*am, Marshall Barton wrote: OTOH, Lyle has been known to come up with innovative ways of doing things that many folks think is impossible. Why not just change the value of the constants? Declare the constants as strings (VBA won't care) and change them in code a needed: Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (Destination As Any, Source As Any, ByVal Length As Long) Const FirstClassStamp$ = "0.42" Const NewFirstClassStamp$ = "0.44" Public Sub UpdateConstants() CopyMemory ByVal StrPtr(FirstClassStamp), _ ByVal StrPtr(NewFirstClassStamp), _ LenB(NewFirstClassStamp) End Sub Public Sub DidItChange() Debug.Print FirstClassStamp '0.42 If VBA.Date() < DateSerial(2009, 5, 11) Then UpdateConstants Debug.Print FirstClassStamp '0.44 End Sub I doubt if there's anyone in the world venturesome enough to actually USE this trick, not me for sure. LOL, but definitely innovative. |
#6
| |||
| |||
|
|
if those values will change as of x date, they can change again farther in the future. |
#7
| |||
| |||
|
|
On Apr 12, 10:19*am, Marshall Barton <marshbar... (AT) wowway (DOT) com> wrote: OTOH, Lyle has been known to come up with innovative ways of doing things that many folks think is impossible. Why not just change the value of the constants? |
|
I doubt if there's anyone in the world venturesome enough to actually USE this trick, not me for sure. |
#8
| |||
| |||
|
|
Am trying to use the following in declarations section of form module. Of course, it won't compile. What's the best way to set my constants inside the If-Then. I need a work-a-round. Can I set Form module constants outside the form module's uppermos declarations section? Option Compare Database Option Explicit Const SmallEnvWt As Double = 0.2059 Const LargEnvWt As Double = 0.625 Const PaperWeight As Double = 0.1666667 If Now < #5/11/2009# Then Const FirstClassStamp As Double = 0.42 Const FirstClassOn9x12 As Double = 0.83 Const OneOunceJumpRate As Double = 0.17 Const Certified3811 As Double = 2.7 Const RetRcpt3800 As Double = 2.2 Const NonMachinableSurcharge As Double = 0.2 Else Const FirstClassStamp As Double = 0.44 Const FirstClassOn9x12 As Double = 0.88 Const OneOunceJumpRate As Double = 0.17 Const Certified3811 As Double = 2.8 Const RetRcpt3800 As Double = 2.3 Const NonMachinableSurcharge As Double = 0.2 End If |
#9
| |||
| |||
|
|
I recall hearing of a similar trick in Cobol where you could change the value of the Goto Label in your code. <shudder> Ah, here we go. http://home.swbell.net/mck9/cobol/style/alter.html |
#10
| |||
| |||
|
|
"tina" <nospam (AT) address (DOT) com> wrote: if those values will change as of x date, they can change again farther in the future. I'm with Tina on this topic. Although if your list of constants will stay constant then there's no reason why all the values couldn't reside in one record with a data. Tony -- Tony Toews, Microsoft Access MVP Please respond only in the newsgroups so that others can read the entire thread of messages. Microsoft Access Links, Hints, Tips & Accounting Systems at http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ |
![]() |
| Thread Tools | |
| Display Modes | |
| |