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 
DLookup
Gayle Alley 
      
2 years ago
I have a textbox on a form that uses DLookup to get the board quantity from the ModelT which works great.  I understand that is not an editable field because it is Dlookup.  

Is there a workaround so that I can either pull the quantity using DLookup and allow the user to enter a quantity manually?  Thanks very much!
Adam Schwanz  @Reply  
           
2 years ago
You could just use an unbound field. In the on current of the form, set the value of the field to the DLOOKUP value. Then you could edit it, and you make an after-update event on the field update the field in your table if you wanted.
Adam Schwanz  @Reply  
           
2 years ago
So something like this, you'd need to add your where criteria and stuff.

Private Sub Form_Current()
    MyField = DLookup("Name", "CustomerT", "CustomerID=" & CustomerID)
End Sub

Private Sub MyField_AfterUpdate()
    If MsgBox("Do you want to update your table to " & MyField & "?", vbYesNoCancel) <> vbYes Then Exit Sub
    CurrentDb.Execute "Update MyTable Set FieldName=" & MyField
End Sub
Richard Rost  @Reply  
          
2 years ago
The questions are WHY are you doing this, and WHAT do you want to do with that number?

But yeah, what Adam said is correct. :)
Kevin Yip  @Reply  
     
2 years ago
Have the user click a button to fill in the textbox with the DLookup value (with the button's Click event), otherwise the user needs to manually enter a value.  This can be done with a bound field too.  See picture below.
Kevin Yip  @Reply  
     
2 years ago

Gayle Alley OP  @Reply  
      
2 years ago
I work for a drywall contractor that uses subcontractors that are paid by piecework - the database calculates the pay a subcontractor is due.   The models table in the database lists the number of boards needed/unit price for each model for the various types of work the subcontractors do (framing, hanging, finishing).  There are times when the sub does not do all the boards and other times, out of the finishes available, it is either one finish or another (not both) even though the builder offers 2 types of finishes on a model (OP or L4)  to their customers, so that is the reason the user may need to change the quantity.  

Thanks to Adam for his suggestion - I must have done something wrong - I tried it on one field and the field is now blank.  I will post images of the code and a copy of one of the orders.
Gayle Alley OP  @Reply  
      
2 years ago
Thank you Kevin - that sounds like a good workaround.  I am not sure how to do that - could you give me more details please?  Thank you very much!
Gayle Alley OP  @Reply  
      
2 years ago

Kevin Yip  @Reply  
     
2 years ago
You use the button's On Click (<--- click here) event to write code that runs when the user clicks the button.  The code simply assigns the DLookup value to the textbox.

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: 5/2/2026 7:10:49 AM. PLT: 1s