Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images | @Reply | Bookmark | Link | Email | Next Unseen |
Dlookup as expression in IIF
David Campbell 
     
2 years ago
I have =DLookUp("VendorPhoneAppCharge","VendorsT",[VendorID]) as default value for control that works.  I decided to place a yes/no check box on form to select if I want default value from table or 0.00. Problem is when I place in IIF as expresion for true it doesn't work.
Adam Schwanz  @Reply  
           
2 years ago
Access is fine with just that [VendorID]? Thats surprising. I'd think you'd have to do "VendorID=" & VendorID
Anyways, this should work
=IIF(CheckboxName,DLookUp("VendorPhoneAppCharge","VendorsT",[VendorID]),0)
Sami Shamma  @Reply  
             
2 years ago
is this in a query or VBA?
David Campbell OP  @Reply  
     
2 years ago
Its in the default value for text box
David Campbell OP  @Reply  
     
2 years ago
=IIF(CheckboxName,DLookUp("VendorPhoneAppCharge","VendorsT",[VendorID]),0)  this is basically what I had put in
David Campbell OP  @Reply  
     
2 years ago
also used  "VendorID=" & VendorID same results  shows default as 0.00 but when I checked phoneApp yes/no it stays on 0.00
Adam Schwanz  @Reply  
           
2 years ago
That would only set the default value, if you want to click the checkbox while the records open and make it change youd have to set the value of the field or make the iif statement in a query or control source and you may need to requery it
Kevin Yip  @Reply  
     
2 years ago
A default value is *already set* for the current new record before you even click the checkbox, so it can't be changed.  You have to enter a new record, then the *next* new record will have the new default value.  This, obviously, is a broken mechanism, so the default value doesn't work.  Just assign whatever value you want to the control whenever you want it.
David Campbell OP  @Reply  
     
2 years ago
I use this method on other parts of database that work fine.  I just can't get this one working so I placed default to 0.00 and need to change the value when value change is needed.
Kevin Yip  @Reply  
     
2 years ago
A default value cannot be "dynamic" (i.e. changing over time or via user actions).  For instance, Now() is a "dynamic" expression.  if you set the default value of a date field to =Now(), you open the form at  7/17/24 7pm, and the default value will remain 7/17/24 7pm until you enter a new record.  If you leave the form open for 4 hours, and it will still be defaulted to 7/17/24 7pm, even though it will be 4 hours earlier than the present value of Now().
Kevin Robertson  @Reply  
          
2 years ago
Kevin Yip  @Reply  
     
2 years ago
For me, the simplest way is to simply assign whatever value you want during the BeforeInsert event.  E.g.:

     Private Sub Form_BeforeInsert(Cancel As Integer)
         Me.datefield1 = Now()
     End Sub

The above code will assign the up-to-the-second Now() value to the field the moment the user types on the new record.  You can use any logic you need to assign whatever value for the new record, at that moment.  It doesn't need to use the default value feature at all.
David Campbell OP  @Reply  
     
2 years ago
The solution was a laugh.  At the new record I hadn't placed in the Vendor yet.  Made a minor change and working

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

Next Unseen

 
 
What's This?

 

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: 10/5/2026 6:07:26 AM. PLT: 1s