I know its probably been asked a million times - however I can't seem to get any examples to work..
In Module1 I have a line: Global gvarMyEmpID As Integer
I then have an opening splash page for the logon process that has a drop down of the employees and an Enter Button
The Enter Button has some code that includes....
gvarMyEmpID = Me!AgentID.Value
SQLtxt = "UPDATE [Version Control] SET [Version Control].[Last Agent] = " & gvarMyEmpID & ";"
DoCmd.RunSQL SQLtxt
I then have the Opening Splash Page close and then the Menu appears - With a text box that has the gvarMyEmpID in the control source however all I get when I run the screen in Form View is "#Name?" in the box.
How can I use this variable in textboxes, Queries - in rowsources, and Event Procedure Code on other pages?
17 2443
I know its probably been asked a million times - however I can't seem to get any examples to work..
In Module1 I have a line: Global gvarMyEmpID As Integer
I then have an opening splash page for the logon process that has a drop down of the employees and an Enter Button
The Enter Button has some code that includes....
gvarMyEmpID = Me!AgentID.Value
SQLtxt = "UPDATE [Version Control] SET [Version Control].[Last Agent] = " & gvarMyEmpID & ";"
DoCmd.RunSQL SQLtxt
I then have the Opening Splash Page close and then the Menu appears - With a text box that has the gvarMyEmpID in the control source however all I get when I run the screen in Form View is "#Name?" in the box.
How can I use this variable in textboxes, Queries - in rowsources, and Event Procedure Code on other pages?
- The Keyword Global is only used for backward compatability - use Public instead:
- Public gvarMyEmpID As Integer
- Public Variables cannot be used as a Control Source for a Control.
- The areas in which they can use used are numerous and range from SQL Statements to code blocks, to Property values, etc.
- The Keyword Global is only used for backward compatability - use Public instead:
- Public gvarMyEmpID As Integer
- Public Variables cannot be used as a Control Source for a Control.
- The areas in which they can use used are numerous and range from SQL Statements to code blocks, to Property values, etc.
I tried that and then on the Menu page entered the following on the "On Load"
Me!Text22.value = gvarMyEmpID
And all i got was a 0 when it should have been a 2 - bing the ID of the staff member I logged in with.
Do I have to call the Module somehow??
I tried that and then on the Menu page entered the following on the "On Load"
Me!Text22.value = gvarMyEmpID
And all i got was a 0 when it should have been a 2 - bing the ID of the staff member I logged in with.
Do I have to call the Module somehow??
Hi, RobH.
I've tried an example and everything works fine with the following.
In public module "Module1"
in form module -
Private Sub Form_Load()
-
Me.Text0 = intVar
-
End Sub
-
-
Private Sub Text0_AfterUpdate()
-
intVar = Me.Text0
-
End Sub
-
Hi, RobH.
I've tried an example and everything works fine with the following.
In public module "Module1"
in form module -
Private Sub Form_Load()
-
Me.Text0 = intVar
-
End Sub
-
-
Private Sub Text0_AfterUpdate()
-
intVar = Me.Text0
-
End Sub
-
Ok I only have 1 module in modules and I have changed to as you have indicated..
In the Logon form 'Logon Button' I have -
intVar = Me.AgentID
-
SQLtxt = "UPDATE [Version Control] SET [Version Control].[Last Agent] = " & intVar & ";"
-
DoCmd.RunSQL SQLtxt
-
Now this does update the Vesion Control tbl correctly.. so the variable is working with-in the logon form..
In the Menu Form I have a text box which should display the ID no.. -
Private Sub Form_Current()
-
Me.Text22 = intVar
-
End Sub
-
I have tried on this form both 'Private Sub Form_Load()' and 'Private Sub Text0_AfterUpdate()'
Ok I only have 1 module in modules and I have changed to as you have indicated..
In the Logon form 'Logon Button' I have -
intVar = Me.AgentID
-
SQLtxt = "UPDATE [Version Control] SET [Version Control].[Last Agent] = " & intVar & ";"
-
DoCmd.RunSQL SQLtxt
-
Now this does update the Vesion Control tbl correctly.. so the variable is working with-in the logon form..
In the Menu Form I have a text box which should display the ID no.. -
Private Sub Form_Current()
-
Me.Text22 = intVar
-
End Sub
-
I have tried on this form both 'Private Sub Form_Load()' and 'Private Sub Text0_AfterUpdate()'
It seems that you are experiencing some very peculiar behavior with your Public Variable. Try changing the Declaration to: NOTE: Let me know how you make out.
Actually - I found the problem ...
I had further down in the coding another IF statement - That was allocating the variable properly..
It was while I was exporting the required modules to a seperate database so i could attach it that i can accross it.
Thanks Guys.
Hey If I want to store the Value of a Yes/No in a variable should I use Variant or String?
Eg I have tbl-UserSecurity which has a field "Admin" being yes/no format.
If I want to Dlookup that value into a public variable so that i can use it for IF statements later. What 'As' should I use in the Public intAdmin as ?????
Thanks Again - already this has the potential to cut so much text from coding and lead off the database from doing these lookup's all of the time..
Rob.
Actually - I found the problem ...
I had further down in the coding another IF statement - That was allocating the variable properly..
It was while I was exporting the required modules to a seperate database so i could attach it that i can accross it.
Thanks Guys.
Hey If I want to store the Value of a Yes/No in a variable should I use Variant or String?
Eg I have tbl-UserSecurity which has a field "Admin" being yes/no format.
If I want to Dlookup that value into a public variable so that i can use it for IF statements later. What 'As' should I use in the Public intAdmin as ?????
Thanks Again - already this has the potential to cut so much text from coding and lead off the database from doing these lookup's all of the time..
Rob.
Hey If I want to store the Value of a Yes/No in a variable should I use Variant or String?
The answer is neither. The value would be stored in a Boolean Type Variable, as in: - 'Public/Global Declaration
-
Public blnAdmin As Boolean
- 'Initialization
-
blnAdmin = True
-
'Evaluates to True and 'blnAdmin = True' appears in the Message Box
-
If blnAdmin Then
-
MsgBox "blnAdmin = True"
-
Else
-
MsgBox "blnAdmin = False"
-
End If
-
The answer is neither. The value would be stored in a Boolean Type Variable, as in: - 'Public/Global Declaration
-
Public blnAdmin As Boolean
- 'Initialization
-
blnAdmin = True
-
'Evaluates to True and 'blnAdmin = True' appears in the Message Box
-
If blnAdmin Then
-
MsgBox "blnAdmin = True"
-
Else
-
MsgBox "blnAdmin = False"
-
End If
-
If I want to store the colour for Fore Colour ie #887433 so that i can use it to effectively make a template for colours across the app would I use String?
I've tried
then in the form On Open -
Me!Label1.ForeColor = intBlue
-
But I get a "Type Mismatch' error when the page loads.
If I want to store the colour for Fore Colour ie #887433 so that i can use it to effectively make a template for colours across the app would I use String?
I've tried
then in the form On Open -
Me!Label1.ForeColor = intBlue
-
But I get a "Type Mismatch' error when the page loads.
Color values as you indicate would have to be LONG Integers - you cannot assign a String Value to a Control's ForeColor Property.
Color values as you indicate would have to be LONG Integers - you cannot assign a String Value to a Control's ForeColor Property.
So how can one find out what can be assigned where?
eg What can be assigned to Source Doc?
So how can one find out what can be assigned where?
eg What can be assigned to Source Doc?
- A String would be assigned to Source Doc.
- If you are not sure about the Variable Type assignments, check the Help Files. You will typically see information such as: Read/write String, returns an Integer, etc.
- A String would be assigned to Source Doc.
- If you are not sure about the Variable Type assignments, check the Help Files. You will typically see information such as: Read/write String, returns an Integer, etc.
Is there a simple way of setting up a Template at all - instead of having to copy the same text to all of the On Open in every form?
Sorry these are probably stupid questions.
So how can one find out what can be assigned where?
eg What can be assigned to Source Doc?
I recommend you to use object browser to view object properties/methods syntax. This also helps to understand object model better.
I recommend you to use object browser to view object properties/methods syntax. This also helps to understand object model better.
Good suggestion, FishVal. The only problem is that the Object Browser can be very intimidating and confusing to a Newbie.
Good suggestion, FishVal. The only problem is that the Object Browser can be very intimidating and confusing to a Newbie.
:) Not sure. For me it was very helpful from the very start.
Despite I had been rather experienced programmer when started designing db's in Access, I was complete Null in OOP. Viewing object model in Object browser gave me a sense of OOP.
:) Not sure. For me it was very helpful from the very start.
Despite I had been rather experienced programmer when started designing db's in Access, I was complete Null in OOP. Viewing object model in Object browser gave me a sense of OOP.
Maybe you do have the right approach, afterall (LOL).
Maybe you do have the right approach, afterall (LOL).
Oh, maybe.
To have an approach is better than to have right one. Bkz to have a right approach means to have no approach at all. LOL.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matt |
last post by:
Greetings,
What are people's thoughts on global variables in C++?
Why are we taught not to use them in programming?
Is it true that if you are running two copies of the C program one
copy can...
|
by: Andrew V. Romero |
last post by:
I have been working on a function which makes it easier for me to pull
variables from the URL. So far I have:
<script language="JavaScript">
var variablesInUrl;
var vArray = new Array();
...
|
by: MLH |
last post by:
A97 Topic: If there is a way to preserve the values assigned to
global variables when an untrapped runtime error occurs? I don't
think there is, but I thought I'd ask.
During development, I'm...
|
by: MLH |
last post by:
I've read some posts indicating that having tons of GV's in
an Access app is a bad idea. Personally, I love GVs and I
use them (possibly abuse them) all the time for everything
imaginable - have...
|
by: Tom Andrecht |
last post by:
I'm trying to write two managed C++ .DLL files for use in a project, and am
running into some trouble that I'm not sure if it's something I'm doing
wrong (this is my first time trying this) or if...
|
by: CDMAPoster |
last post by:
About a year ago there was a thread about the use of global variables
in A97:
http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157
Best Practices by Kang...
|
by: Sandman |
last post by:
I dont think I understand them. I've read the section on scope in the
manual inside out.
I'm running PHP 5.2.0 Here is the code I'm working on:
//include_me.php
<?php
$MYVAR = array();
global...
|
by: weaknessforcats |
last post by:
C++: The Case Against Global Variables
Summary
This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
|
by: istillshine |
last post by:
When I control if I print messages, I usually use a global variable
"int silent". When I set "-silent" flag in my command line
parameters, I set silent = 1 in my main.c.
I have many functions...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |