Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Text Box required if
Charles Zigler 
   
5 years ago
So I have a form that is a fillable form with combo boxes that reference a table and you select whatever and put in time to complete and save, the form then saves to a different table and I want to make a text box that is hidden and shows up and is only required to be filled if the "Status" is "Overdue" asking for a reason why it is overdue. The problem I am facing is that the "Status" is a calculated field in a query and I can't figure out how to reference that field in the query.
Alex Hedley  @Reply  
           
5 years ago
Is your Form bound to a Table or Query?
Is the Status Field on your Form?

AfterUpdate when it's chosen to then show hide the required field.
Charles Zigler OP  @Reply  
   
5 years ago
The form is bound to a table, which is where it fills in it's data. the status field is not on this form, I do have it on another form (that is bound to the query) that is for "display purposes"
Charles Zigler OP  @Reply  
   
5 years ago
I could probably reference the "Status" on the form by using "Forms!testfrm!Status" but how would I get it to look at the correct row, which would be determined by the combo boxes. for example, first combo city/state, then customer, then order, now I need to figure out if that order is overdue or not and if it is require a reason to be entered
Alex Hedley  @Reply  
           
5 years ago
DLOOKUP with criteria
Charles Zigler OP  @Reply  
   
5 years ago
So, I created a new text box on the form so I could easily reference to determine the status and I set the control source to:
=DLookUp("[%TilDueStatus]","QryPMavg",[Forms]![frmPMfill]![Machine] & [Forms]![frmPMfill]![MaintPoint] & [Forms]![frmPMfill]![Maintwork])
but it starts out with saying "overdue" and then when I start selecting things from the combo boxes it just says error
Adam Schwanz  @Reply  
           
5 years ago
That's an invalid where criteria it needs to be like

=DLookUp("[%TilDueStatus]","QryPMavg","Machine=" & [Forms]![frmPMfill]![Machine] & " and MaintPoint=" & [Forms]![frmPMfill]![MaintPoint] & " and Maintwork=" & [Forms]![frmPMfill]![Maintwork])
Charles Zigler OP  @Reply  
   
5 years ago
Well, I tried everything I could think of. I tried it your way, tried adding brackets, tried adding spaces and capitalizing "and", I also tried to reference a different form called frmPM instead of referencing a query. All I ever get is #error
Charles Zigler OP  @Reply  
   
5 years ago
I also have it set to requery after update of the last combo box
Richard Rost  @Reply  
          
5 years ago
What kind of values are Machine, MaintPoint and MaintWork? If they are strings you have to add more double quotes.
Richard Rost  @Reply  
          
5 years ago
Charles Zigler OP  @Reply  
   
5 years ago
Should just be normal. My database:
LINK REMOVED
If anyone wants to take a look at it. If not, no problem I'll just keep trying stuff.
Alex Hedley  @Reply  
           
5 years ago
=DLOOKUP("[%TilDueStatus]","QryPMavg","Machine='" & [Forms]![frmPMfill]![Machine] & "' AND MaintPoint='" & [Forms]![frmPMfill]![MaintPoint] & "' AND Maintwork='" & [Forms]![frmPMfill]![Maintwork]) & "'"
Alex Hedley  @Reply  
           
5 years ago
Does your field name start with a %? - %TilDueStatus
Charles Zigler OP  @Reply  
   
5 years ago
machine, maintpoint, and maintwork are all combo boxes, that reference corresponding fields in a table.
Richard Rost  @Reply  
          
5 years ago
What do you mean by "normal?" It's important what DATA TYPE those fields are. Are they ID's (Autonumbers?) Long Integers? Currency values? Text Strings? Help us to help you.

And no... we don't allow external links here in the forum for you to post your database. Please read the Rules. If you want someone to look at your database, go to the Access Developer Network page.
Alex Hedley  @Reply  
           
5 years ago
What do you mean by NORMAL? What are you saying is NORMAL the Machine Field etc.
Rich is asking it's type like TEXT, NUMBER etc in the Table Definition
Charles Zigler OP  @Reply  
   
5 years ago
Yes, my field name does start with %
Charles Zigler OP  @Reply  
   
5 years ago
oh, it is all short text
Richard Rost  @Reply  
          
5 years ago
That still doesn't help me. What is the combo box BOUND TO? And ID? A Text Value? If you don't understand what that means, I suggest you watch these two videos:

Value List Combo Box
Relational Combo Box
Richard Rost  @Reply  
          
5 years ago
Then if it's short text you need quotes around it, like Alex showed you. See the Double Double Quotes video I pointed you to earlier.
Richard Rost  @Reply  
          
5 years ago
Keep in mind, we love helping people out here, but we're here to TEACH YOU and HELP YOU LEARN how to do these things. There are a million videos on my site to teach you this stuff... but you have to be willing and open to learning. We're not just here to give you answers. I direct you to videos so you can learn how to do this stuff yourself. :)
Charles Zigler OP  @Reply  
   
5 years ago
So, the form is bound to a table, the combo boxes are bound to short text fields in said table, with row source of select distinct whatever, row source table/query. If that doesn't answer the question, just know I am currently watching your videos to find out if I know what is being talked about or not.
Charles Zigler OP  @Reply  
   
5 years ago
I am not seeing where I would need double double quotes. I will try to explain again, here is my current control source:=DLookUp("[%TilDueStatus]","frmPM","Machine=" & [Forms]![frmPMfill]![Machine] & " and MaintPoint=" & [Forms]![frmPMfill]![MaintPoint] & " and Maintwork=" & [Forms]![frmPMfill]![MaintWork])
Ok, so that control source is for the text box I created in the form called frmPMfill.
frmPMfill is bound to a table called tblPMentered, so upon saving the form it fills in the table.
I then have a query that takes tblPMentered and tblTask to assign the frequency at which the PM should be performed and inside the query I have several equations one of them being: %TilDueStatus: IIf([DaysTilDue]/[Frequency (#)]*100>=10,"Good ",IIf([DaysTilDue]/[Frequency (#)]*100<>0,"Warning <10%",IIf([DaysTilDue]/[Frequency (#)]*100=0,"Overdue")))
I then made a new query and called it QryPMavg and just put in everyfield to eliminate the equations and just have the values.
To be continued...
Charles Zigler OP  @Reply  
   
5 years ago
I then have a form called frmPM which is bound to the query QryPMavg, and it is a continuous form, and displays the fields from QryPMavg and I set some conditions to highlight the "%TilDueStatus" field in green, yellow, red.
My goal is on the frmPMfill, I have a combo box that selects the machine, maintpoint and maintwork from tblTask and i want a text box to display the "%TilDueStatus" from either the query or the form that both reference the same thing and they are both called the same thing. I am not understanding what is wrong with my dlookup for that textbox control source.
Charles Zigler OP  @Reply  
   
5 years ago
oops messed up when i said QryPMavg displays from QryPMavg i meant it displays from QryPMrun which is the query that has all of the equations
Alex Hedley  @Reply  
           
5 years ago
What should your criteria look like?
Write it out by hand first.
Example
" Machine='A' AND MaintPoint='B' AND Maintwork='C' "
Then work backwards
Richard Rost  @Reply  
          
5 years ago
Not to confuse you, but Alex prefers single quotes. I like double-double quotes.

S = " Machine='A' AND MaintPoint='B' AND Maintwork='C' "

is the same as

S = " Machine=""A"" AND MaintPoint=""B"" AND Maintwork=""C"" "

I don't like using ' in strings that could possibly have a ' in them, like a LastName field: D'Angelo
Richard Rost  @Reply  
          
5 years ago
I'd suggest simplifying things and just use ONE criteria for now. Get it working. Then add your AND conditions in.
Charles Zigler OP  @Reply  
   
5 years ago
I think the problem with that, correct me if I'm wrong, if I try to do just machine it won't work because it needs to be unique. So, in my query I have machine: machine1 maintpoint: x maintwork:a then machine1 x b machine2 x a, the only way for it to be unique is to use all three columns.
Richard Rost  @Reply  
          
5 years ago
Right... long term you're going to want all three... but just for now while you're learning the syntax try one.
Charles Zigler OP  @Reply  
   
5 years ago
Wow, I really appreciate the help. I did exactly what you said, I just deleted all my data so I could have machine to be unique and did the dlookup for it and got it to work then added in the other condition or criteria and I got it to work thanks a bunch. Super appreciate it, I can't express my gratitude enough
Scott Axton  @Reply  
        
5 years ago
Just following along and I'm going to muck things up a bit for you.  

According to the Microsoft site the % is a reserved symbol and could cause you issues.  You might get away with it for now but in the long run it could come back to bite you.  See the article here:  Access Reserved Words and Symbols

In naming your fields I really suggest you stick to just letters and numbers - that is the safe bet. (NO spaces)

When I'm up against a difficult formula I like to "hard code" values in just to make sure it works.  Then I start switching out - one at a time - for the variables.  I get the best results that way.
Alex Hedley  @Reply  
           
5 years ago
Glossary Item too.
Richard Rost  @Reply  
          
5 years ago
Charles, glad you got it working. Keep learning. :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/22/2026 9:55:21 PM. PLT: 0s