I am having trouble declairing a variable so that I call get it's value in one event but then call to that variable to retrieve the value in other events (all on the same form.
The variable I am trying to declair is
I have tried: -
public ststatus as string ' the counter is always 1 even though a Dcount is performed from the table, and the values that are sent to the table via inert query are never sent to the table
-
-
Option explsit
-
Dim ststatus as string ' ststatus only holds a value onclick event, in other events ststaus is 0 or null (and it was never set to that value, I tested with textboxes to varify that a value should be present.
-
-
public sub ok onclick()
-
ststatus = Dcount ....(vailid dcount statmdnt)
-
end sub
-
public rec ()
-
If ststmtus is >3 then msgbox "count is" & chr$(32) & ststatus ' and the count is always 0 , even though the value add up to definetly more then 0 in the table
-
Thanks for helping, I hope my code snippets are enough to solve this problem.
3 1223
Hi. There are spelling errors in the names listed for your global variable and some of the code which makes proper comment on what you have tried impossible, as the errors shown may just be because you typed the line incorrectly here but not in your code (option explsit instead of Option Explicit for instance - compiler would simply not accept explsit as a valid argument).
If your public (global) variable is declared in a public code module (not in a form module or similar) it can be set and read by code in any code module in your database, assuming that the references to it are correctly spelled. If you are sure you are referring to it correctly I would suggest that you set breakpoints in the VBE editor and step through the lines of code that set or refer to your global. If you hover your mouse over the name of a variable within code stopped by breakpoint you will see the live values for all the variables and object references.
-Stewart
ADezii 8,834
Recognized Expert Expert
I am having trouble declairing a variable so that I call get it's value in one event but then call to that variable to retrieve the value in other events (all on the same form.
The variable I am trying to declair is
I have tried: -
public ststatus as string ' the counter is always 1 even though a Dcount is performed from the table, and the values that are sent to the table via inert query are never sent to the table
-
-
Option explsit
-
Dim ststatus as string ' ststatus only holds a value onclick event, in other events ststaus is 0 or null (and it was never set to that value, I tested with textboxes to varify that a value should be present.
-
-
public sub ok onclick()
-
ststatus = Dcount ....(vailid dcount statmdnt)
-
end sub
-
public rec ()
-
If ststmtus is >3 then msgbox "count is" & chr$(32) & ststatus ' and the count is always 0 , even though the value add up to definetly more then 0 in the table
-
Thanks for helping, I hope my code snippets are enough to solve this problem.
You want to limit the scope of your Variable Declarations to the tightest scope possible without losing functionality. If a Variable is be used only within the context of a single Form, then by all means, Declare it in the General Declarations Section of your Form as follows: -
Private variablename As Data Type
Note: Do not declare a Variable as Public under the previous conditions.
Ok, I solved this but not by declareing variable I traped arrors and used them to my advantage, since I wasn't having anyluck with using a call to a string that contained a value from other events within the save form.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lawrence |
last post by:
I'm trying to read up on the rfc's that govern form inputs. Much of
what I'm reading is stuff I didn't know before and some of it is
alarming. This one left with me questions:
...
|
by: rick |
last post by:
Noob problem. I prefer to keep all my scripts in an external '.js' file.
I am currently loading the external '.js' file from the header. Problem is I
would like to declare
a global variable in the...
|
by: Random Task |
last post by:
How do i run exec and catch stdio and stderr in a local string vairable
(not a file) ...
Thanks very very much,
Jim
|
by: Johm |
last post by:
In my codes i am often referring to one and the same controls.Is it
possible
to declare these controls only once and then insert them in all my
functions and subs?
For example, i am often...
|
by: John Dann |
last post by:
Trying to declare a structure that will contain a couple of fixed-size
arrays. I'm trying eg:
Structure IndexRecord
Dim testarray(16) as Byte
etc
End Structure
But vb.net is refusing to let...
| |
by: Altman |
last post by:
I am having problems with Declaring a function from a dll. I had it work in
VB 6 but I can't get it to work in VB.net. This was the call in VB6
Public Declare Function MBTConnect Lib "MBT" (ByVal...
|
by: mark.moore |
last post by:
I know this has been asked before, but I just can't find the answer in
the sea of hits...
How do you forward declare a class that is *not* paramaterized, but is
based on a template class?
...
|
by: roamnet |
last post by:
hi
i created database file with .mdf extention ,sql server as a source
and use grid view to display data
there're no problem in data retrieve and display,but i want to edit it
or insert new...
|
by: yu83thang |
last post by:
Hi,
May I know how to declare a Class in C++ window application form? Below is my code and error as shown below as well.
here is my class declaration:
ref class CLoadObj {
public:
|
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: 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: 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...
|
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?
| |