Solved

using IsLoaded in a query

Posted on 1998-04-16
7
336 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
Comment Utility
Edited text of question
0
 
LVL 2

Author Comment

by:Bangerter
Comment Utility
Edited text of question
0
 
LVL 5

Expert Comment

by:cekman
Comment Utility
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 17

Expert Comment

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

Expert Comment

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

Author Comment

by:Bangerter
Comment Utility
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
Comment Utility
Thanks! CEkman
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now