Solved

using IsLoaded in a query

Posted on 1998-04-16
7
352 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
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
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

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…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
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…

791 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