IWETHEY v. 0.3.0 | TODO
1,095 registered users | 1 active user | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Public Universal variable.
Is it possible to make a universally available variable in Access? I need two vars to keep track of the current batch and the current year (i.e., incident year on forms people are entering). Load a form, set the batch to, say, CurrBatch, and then use the value for CurrBatch for subsequent records that are entered. I've been using class modules but it's causing problems. All I want is a stupid simple global variable.
New Put them in a module.
And declare them Public.

(Aside: Global variables - <<shudder>>)
bcnu,
Mikem

I don't do third world languages. So no, I don't do Java.
New Several ways
1. As mm says, use a Public var.
2. Make a Singleton macro.
3. Hmm...I'm using a database, and I have some data I want to manage...hmmm.
I was one of the original authors of VB, and *I* wouldn't use VB for a text
processing program. :-)
Michael Geary, on comp.lang.python
New Well. . . . .
I ended up rearranging things a bit and used the class module I already had. Still getting an odd error where the instance gets dropped for whatever reason. The users manage to make it happen a lot, but I hardly ever do so it's hard to figure out why it's doing it. It's happening less since they've worked with it a little, so I guess I can put it on the back burner for a while.
New Is the object globally scoped?
bcnu,
Mikem

I don't do third world languages. So no, I don't do Java.
New Re: Is the object globally scoped?
I have it as such in a module.

Does Access kill any objects when it hits an error message?

Other question: Is there a way to pass a parameter to an existing query before it runs? Like:

INSERT INTO tblMain ( BatchNo, MIRFNumber )
SELECT tblBLS_Add.BatchNo, tblBLS_Add.MIRFNumber
FROM tblBLS_Add
WHERE (((tblBLS_Add.BatchNo)=XXXX));


Where "XXXX" is a value supplied by the user.
New Answering the other question
See [link|http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q200/1/90.asp&NoWebContent=1|http://support.micro...sp&NoWebContent=1] to see how to do it.

Cheers,
Ben
"good ideas and bad code build communities, the other three combinations do not"
- [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
New If Ben's answer doesn't help.
Ben's answer is the answer if you are using ADO in your app.
If not, and I'm not sure if you're coding your queries entirely, but if you are using Access's query designer, you can right-click in the area of the designer where the tables are and on the context menu will appear "Parameters..." you can create a parameter there and then refer to the parameter in your code.

I'll assume Ben's link will work for you - if you want to know how to do it another way, lemme know ;-)

>Does Access kill any objects when it hits an error message?
Not that I am aware of. It shouldn't, but then, it is Access we're talking about.

If Ben's answer doesn't help, can you tell me the answers to:

1) Which version of Access are you using?
2) Are you using ADO or OpenQuery to fire off your queries?
3) Is the SQL of your queries hand-coded into a module, or are you creating queries with the designer?

(Aside: if you use the query designer and save the queries in the mdb as opposed to having the SQL coded into a module, you will get a slight performance boost if it Access tables you are hitting. From ADO's perspective, those Access queries are stored procedures)
bcnu,
Mikem

I don't do third world languages. So no, I don't do Java.
New PARAMETERS also available in Access SQL
If not, and I'm not sure if you're coding your queries entirely, but if you are using Access's query designer, you can right-click in the area of the designer where the tables are and on the context menu will appear "Parameters..." you can create a parameter there and then refer to the parameter in your code.


Look up the PARAMETERS keyword. It should lead you to some solution like (off the top of my head):

PARAMETERS [Batch Number?]
INSERT INTO tblMain ( BatchNo, MIRFNumber )
SELECT tblBLS_Add.BatchNo, tblBLS_Add.MIRFNumber
FROM tblBLS_Add
WHERE (((tblBLS_Add.BatchNo) = [Batch Number?]));

...and the user receives an InputBox whose prompt is "Batch Number?".

Etcetera.
I was one of the original authors of VB, and *I* wouldn't use VB for a text
processing program. :-)
Michael Geary, on comp.lang.python
     Public Universal variable. - (acagle) - (8)
         Put them in a module. - (mmoffitt)
         Several ways - (FuManChu)
         Well. . . . . - (acagle) - (5)
             Is the object globally scoped? -NT - (mmoffitt) - (4)
                 Re: Is the object globally scoped? - (acagle) - (3)
                     Answering the other question - (ben_tilly)
                     If Ben's answer doesn't help. - (mmoffitt) - (1)
                         PARAMETERS also available in Access SQL - (FuManChu)

I could be totally wrong.
50 ms