Solved

using IsLoaded in a query

Posted on 1998-04-16
7
346 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

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…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

809 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