JustJim 407
Recognized Expert Contributor
Hi All
I have a little application I'm working on for the local Department of Education. There is a "Main Menu" form that has a toggle button on it to show/hide the Database Window. When it is clicked it does the following - Private Sub tglDBwindow_Click()
-
DoCmd.SelectObject acTable, , True
-
-
If tglDBwindow Then
-
Me.SetFocus
-
'Me.tglDBwindow.DefaultValue = "True"
-
Me.OpenArgs = True
-
Else
-
DoCmd.RunCommand acCmdWindowHide
-
'Me.tglDBwindow.DefaultValue = "False"
-
Me.OpenArgs = False
-
End If
-
-
End Sub
As you can see, I am trying to get the form to remember the state of the toggle button so that when users navigate away from the main menu form to another form and back again (all unused forms are closed by the opening of the next one (this could be a mistake but it is neat and tidy!))
Now although Access Help says that both DefaultValue and OpenArgs are read/write, when I run the above code (with either DefaultValue or OpenArgs remarked out) I get the following error msg.
Error 2135 The property is read only and cannot be set.
Am I going about this the right way? Is there a better way?
5 10076
Hi All
I have a little application I'm working on for the local Department of Education. There is a "Main Menu" form that has a toggle button on it to show/hide the Database Window. When it is clicked it does the following - Private Sub tglDBwindow_Click()
-
DoCmd.SelectObject acTable, , True
-
-
If tglDBwindow Then
-
Me.SetFocus
-
'Me.tglDBwindow.DefaultValue = "True"
-
Me.OpenArgs = True
-
Else
-
DoCmd.RunCommand acCmdWindowHide
-
'Me.tglDBwindow.DefaultValue = "False"
-
Me.OpenArgs = False
-
End If
-
-
End Sub
As you can see, I am trying to get the form to remember the state of the toggle button so that when users navigate away from the main menu form to another form and back again (all unused forms are closed by the opening of the next one (this could be a mistake but it is neat and tidy!))
Now although Access Help says that both DefaultValue and OpenArgs are read/write, when I run the above code (with either DefaultValue or OpenArgs remarked out) I get the following error msg.
Error 2135 The property is read only and cannot be set.
Am I going about this the right way? Is there a better way?
Couple of ways,
You could create a small one field table to hold the true false...set the toggle's control source to that field.
You could set a global variable to true or false, then read it when your form opens. Boolean fields (global or not) default to false.
J
From Access Help:
OpenArgs Property
This property is available only by using a macro or by using Visual Basic with the OpenForm method of the DoCmd object. This property setting is read-only in all views. JustJim 407
Recognized Expert Contributor
Thanks Guys.
As usual, it's so easy and obvious once someone points it out.
Again, Thank you
Jim
NeoPa 32,557
Recognized Expert Moderator MVP
FYI Jim.
OpenArgs is set by the call to open the form. It is passed from the calling code and, as such, is read-only within the form that has been called.
However, as this is only accessible to the code in the called form if accessed as a first thing, it is generally used by immediately copying the value (Me.OpenArgs) into a separate, publicly available variable for any later references. Clearly, once this has been done, the public variable is not only available for reading, but can also be overwritten where required too. An example of when this might be required is when a date is passed but you need a date string in a particular format.
Hope this helps.
NeoPa 32,557
Recognized Expert Moderator MVP
I just thought I'd add a further bit of explanation more specific to the original question.
A fundamental difference between the two approaches (OpenArgs & a table) is that OpenArgs is session dependent, whereas tables keep the information until it's changed.
In real terms this means that if the information is only required within the current session then OpenArgs would be appropriate (although the table could be used for this in almost all situations), but if the information is required to persist across various current sessions, or even between separated sessions, then the table is required.
I hope this clarifies the issues a little.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Aravind |
last post by:
Hi folks.
I have a form, frmHistory, which has 3 toggle buttons (1 of which is
tglName, which I will be using to demonstrate my problem). The buttons
are used to sort the form (explanations...
|
by: John |
last post by:
Hi
How can I create a toggle button on a toolbar that would enable/disable
editing on the current form?
Thanks
Regards
|
by: Neil Coleclough |
last post by:
I am constructing a database to process product returns for my Company.
I have a number of toggle buttons to identify the stage to which each
return has been processed. For example, clicking the...
|
by: Steven |
last post by:
Can anyone tell me how to toggle the "Caps Lock" key?
Thanks in advance
|
by: Mel |
last post by:
Hi, is there any way I can implement toolstrip toggle button simular to the
MS Word alignment button?
if one toggle button already pressed down, if user click on the "pushed down
button", the...
| |
by: Killer42 |
last post by:
Hi all.
I have a frame with some toggle buttons in it. All is working fine, except that the user can't tell which option is selected to begin with. How do I set one of the toggle buttons to the...
|
by: newfie912 |
last post by:
I have an online application used for grading students. On one of the
pages, I have a table with two rows and each row has 16 cells. The
upper row contains the letter grade (A, A-, B+, B, etc)...
|
by: Jeffrey Christiansen |
last post by:
I wanted to add a toggle button to a VB2005 form to be used for a
simple Windows Application (i.e. compiled to a "*.exe"), so I added
the ActiveX Microsoft Forms Object toggle button, however I...
|
by: ethanhines |
last post by:
I am trying to dynamically change the value of a filed using a toggle button in a form it is not a yes or no question. I want it to change a value in a table based on it"s state. Toggled on="6...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |