Solved

using IsLoaded in a query

Posted on 1998-04-16
7
358 Views
Last Modified: 2012-05-04
i have a form that can be opened from either of 2 different forms.it is called credit. in the query that is the control source for credit i tried to put this in the criteria of the AccountNumber field.

iif(IsLoaded("MyfirstForm"),forms![MyFirstForm]![AccountNumber],forms![MySecondForm]![AccountNumber])

this in theory, as i see it, should check to see if MyFirstForm is open and if it is then to pass the AccountNumber to the credit form and pull up the appropriate record. otherwise it should pass the AccountNumber from MySecondForm (if MyFirstForm is not opened the only other form that can call the credit form is MySecondForm).

but, when i run it even if MyFirstForm is not open, but MySecondForm is, it still asks me for a value to the field forms![MyFirstForm]![AccountNumber].

i hope this all makes sense.

0
Comment
Question by:Bangerter
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Author Comment

by:Bangerter
ID: 1973908
Edited text of question
0
 
LVL 2

Author Comment

by:Bangerter
ID: 1973909
Edited text of question
0
 
LVL 5

Expert Comment

by:cekman
ID: 1973910
I do this exact same thing in one of my applications. You can't use the iif statement. You must create a FUNCTION in a separate module then call the functionin the criteria statement of your query. For example - create a function called RETURNVAL() that checks which form is open and returns the value you need. Then, in the criteria statement of the query just put  RETURNVAL()

Hope this helps!
Carla
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:ramrom
ID: 1973911
Realize that iif evaluates ALL of its arguments, regardless of value of the first.
0
 
LVL 17

Expert Comment

by:ramrom
ID: 1973912
Realize that iif evaluates ALL of its arguments, regardless of value of the first.
0
 
LVL 2

Author Comment

by:Bangerter
ID: 1973913
Trygve i never did see your solution because of some kind of error so i cant evaluate it.

Cekman if you will lock this question i will give you the points

Thanks
Brent
0
 
LVL 5

Accepted Solution

by:
cekman earned 50 total points
ID: 1973914
Thanks! CEkman
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question