IIF statement to determine a closed form

AceBK

Registered User.
Local time
Today, 14:45
Joined
Dec 2, 2011
Messages
75
Hello, I have been working with Access for a little while now, but by no stretch would I consider myself "Experienced". I am running Access 2010 and have run stuck on an issue. Please help.

I am building a form that is finding the "Docket Numbers" from three different forms. In order to get these numbers, I put in three text boxes with these statements:

Text box1
=[Forms]![Jobslist]![Docketnumber]

Text box2
=[Forms]![Jobslist2]![Docketnumber]

Text box3
=[Forms]![Jobslist3]![Docketnumber]

However, not all three forms will necessarily be open at one time so I am trying to use an Iif statement to check if the form is open. I can't seem to figure out the function to check if the form is open. I am looking for something along these lines:

Text box1
=iif([Forms]![Jobslist] = closed,"",[Forms]![Jobslist]![Docketnumber]

What i need to figure out is what to used instead of "= closed".

Thank you for help
 
Bob,

Thank you for your response. I did what you suggested and I came up with an error message. I have attached a screen shot of the message. Do I need to change "strformname" to something, or does it stay as is.

Ace
 

Attachments

  • Error message.JPG
    Error message.JPG
    12.3 KB · Views: 132
Option Compare Database
Function IsOpen(strFormName As String) As Boolean
If CurrentProject.AllForms(strFormName).IsLoaded Then
IsOpen = True
Else
IsOpen = False
End If
End Function

That is my Module1 code.

In my text boxes I have

Textbox 1
=IIf(IsOpen("Jobs List"),[Forms]![Jobs List]![Docket_Number],Null)

Textbox 2
=IIf(IsOpen("Job List 2"),[Forms]![Jobs List 2]![Docket_Number],Null)
 
Bob,

Thank you so much for helping me with this. So I added the new function and changed the control source of my fields, however, I get the same error message as before. When I hit the 'debug' button, this is the line that gets highlighted in yellow:

If CurrentProject.AllForms(strFormName).IsLoaded Then

Any ideas?
 
Bob, you are very good. I was missing the s in 'Jobs list 2'. After that fix, it worked. Thank you for your help
 

Users who are viewing this thread

Back
Top Bottom