I have a number of global constants in a module made for that purpose. They are primarily price constant that rarely change, but also includes VAT and discount rates.
How can I alter these values from a form?
I have a form with the values showing in textboxes, but they are not editable.
Am i going about this the right way?
Thanks (again) for any help you can give.
RPE
Well I don't want to have good weather in this season down in Australia as its too hot here....Besides since the bloody flood passed by last month, most places are still maintaining power by renting generators, I wish I'm replying you in a swimming pool...
Back to topic, indeed a constant is not editable, sorry that I missed out this part. If possible, try search the constant variable where its created, it must be within the modules or classes. Or it can be a datatype function that generates with certain methods.
7 1991
Have you tried making a command button to save the new values?
As the textboxes simply read once from the global variables, then it could be re-assign with new values by executing an event such as command button's On_Click()
Thanks for the reply colintis:
I'd been working flat out on a complicated (for me!) database for hours when I came across this problem. I see what you mean about the cmdButton, but I also can't actually alter the value in the textbox - the same as if it were locked. I'm guessing it's something to do with the 'variables' being global and/or in a separate module, but I can find nothing on this in any of my books or online.
The 'VAT issue' (sales tax in most countries I think) must be a common one, but having already tried to put such values into a table, I figured the best way would be a constant...but how does one alter a constant...by definition I guess you don't...maybe a 'normal' variable?
Thinking while typing! Bet you got better weather outside your window than I have!!
Thanks again.
stonward.
Well I don't want to have good weather in this season down in Australia as its too hot here....Besides since the bloody flood passed by last month, most places are still maintaining power by renting generators, I wish I'm replying you in a swimming pool...
Back to topic, indeed a constant is not editable, sorry that I missed out this part. If possible, try search the constant variable where its created, it must be within the modules or classes. Or it can be a datatype function that generates with certain methods.
I hope the flood literally 'passed you by'....
I've been going about this 'constant' problem the wrong way of course...I'm gonna re-ask the question from where I am now: I've placed a public variable in a 'declarations' module, initialized it with a value and used a function to call it on my form. Works great, but still can't figure how to alter the value!
Thanks for your time thus far Colintis.
stonwardR
NeoPa 32,556
Expert Mod 16PB
It's good sense to post the new question separately (found From a txtbox on a form, how can I alter an initialized variable value?). I read it but couldn't see any way it could make sense. Maybe that's because I don't make the sort of assumptions you would Royston. Maybe Colintis would fare better. I'm happy to look again though if it can be made clearer.
@ALL - You can actually modify the Value of a CONSTANT Permanently from within a Form. You would Open the Code Module containing the CONSTANT Declaration, Search for the Current Value assigned to the CONSTANT, change it, Close and Save the Module, then return Focus to the Form where the Code originated.
As ADezii says, this can be done in code. I do it all the time when changing assigned drives.
Obviously you would need to adapt the text below to match your own constant string, but this is the code I use. -
Private Sub cmdChangeDrive_Click()
-
On Error GoTo cmdChangeDrive_Click_Err
-
Dim db As Database
-
Dim td As TableDef
-
Dim i As Integer, j As Integer, var As Variant
-
Dim GotPrimary As Boolean
-
Dim strAttach As String
-
Dim strNewAttach As String
-
Dim strNewCode As String
-
Dim strNewMDW As String
-
-
Dim mdl As Module
-
Dim intLine As Integer, strLine As String
-
-
'"c:\Education\EducationCode.mdb"
-
strNewCode = NewLiveCode & Right(LCode, Len(LCode) - 1)
-
-
'";DATABASE=c:\Education\EducationData.mdb"
-
strNewAttach = Left(LData, 10) & NewLiveData & Right(LIVEDATA, Len(LIVEDATA) - 11)
-
-
'"c:\Education\Education.mdw"
-
strNewMDW = NewLiveMDW & Right(LMDW, Len(LMDW) - 1)
-
-
DoCmd.OpenModule "basConstants"
-
' Return reference to Module object.
-
Set mdl = Modules("basConstants")
-
-
For intLine = 1 To mdl.CountOfDeclarationLines
-
strLine = mdl.Lines(intLine, 1)
-
If InStr(strLine, "LIVECODE") > 0 Then
-
mdl.ReplaceLine intLine, "Global Const LIVECODE = " & Chr(34) & strNewCode & Chr(34)
-
End If
-
If InStr(strLine, "LIVEDATA") > 0 Then
-
mdl.ReplaceLine intLine, "Global Const LIVEDATA = " & Chr(34) & strNewAttach & Chr(34)
-
End If
-
If InStr(strLine, "LIVEMDW") > 0 Then
-
mdl.ReplaceLine intLine, "Global Const LIVEMDW = " & Chr(34) & strNewMDW & Chr(34)
-
End If
-
Next
-
DoCmd.Close acModule, "basConstants", acSaveYes
-
-
cmdChangeDrive_Click_Exit:
-
Exit Sub
-
cmdChangeDrive_Click_Err:
-
MsgBox Err.Description & " in cmdChangeDrive_Click"
-
Resume cmdChangeDrive_Click_Exit
-
End Sub
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Krisztian Kepes |
last post by:
Hi !
I want to create an module and I want to use some Global Constant in it.
How to I create an global constant in module what is accessable in from other modules ?
like this example:
***...
|
by: Matt Smolic |
last post by:
02.06.04
I need some help displaying a public variable on a form. The variable is
declared and initilazied in a module at startup (and declared Public). I
have verified this with a...
|
by: Lupina |
last post by:
How to do global pointer , which indicates on the second form ?
If I want e.g. invoke another form I do it like this :
private: System::Void menuItemDlg_Click(System::Object * sender,...
|
by: Anton |
last post by:
Hi folks,
Is there any way to retrieve a global declared constant from another
database. I want to use it for version tracking purposes. The constant
that I am after is and will remain in a static...
|
by: tkhouk |
last post by:
I have a small form with two unbound look-up fields (one for an ID and one for last name). Each unbound field has a command button that actually goes to my table and brings in the records.
How can...
|
by: SpreadTooThin |
last post by:
How do I define a constant that I can use in my script...
For example lets say I have a file called constants.py and in there I
have PI = 3.14
in my test script I do:
from constants import *...
|
by: luanhoxung |
last post by:
hi all!!
i face to a new trouble.
in my form, i have a textbox(unbound) that informs details of product when
i choose the value of combo box(IDPro).
it is ok when i choose the first value of...
|
by: DWolff |
last post by:
I'm somewhat new to Access, and have no VB experience at all (except for modifying existing code where obvious).
I built a data entry form that works fine. Typically, a client will call in and...
|
by: tech.rawsteak |
last post by:
I have a function that retrieves a user's login name from their
workstation and looks it up on an employee table to return their full
name (ie: jsmith -John Smith). Their full name is then...
|
by: hbaf208 |
last post by:
I have a combobox on a subform that is based on an SQL that uses a listbox on the unbound parent form as the criteria. When the form is first loaded, it works perfectly, limiting the dropdowns to...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |