Solved

using IsLoaded in a query

Posted on 1998-04-16
7
360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

738 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