Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  View Answers    Answer this question    Ask a question  
 

wilpeter
Feb 12, 2012, 12:48 PM
Version 2002 of Access. I have a Menu form (not connected to a table). It mostly contains macro buttons, but one field should reflect the last assigned autonumber in a receipt table (called tblTaxReceiptNumbers, fieldname TaxReceiptNo) I have a query called qryLastReceiptNo that displays one field TaxReceiptNo sorted Descending with Top Values =1 that wonderfully gives me the number; however I can't display it in my menu field. I get the dialog/error "The object doesn't...etc." I've tried the SetValue in a macro with the two properties identified...same result. Everything else seems to work. Pressing Ctrl G and looking in References shows VB for Apps; Access 10.0 object library; OLE Automation; and MS ActiveX Data Objects 2.1 Library. Anything else I should be checking?

ScottGem
Feb 15, 2012, 06:52 PM


Use a DLookup to pull the value from your query or a DMax to pull the value from the table. Use the expression as the ControlSource of the text control.

wilpeter
Feb 21, 2012, 10:40 AM
Thanks for your response. I've tried both these expressions in the Control Source property of the table's field Lastest:
DMax([TblReceiptNumbers]![TaxReceiptNo])
DLookup([qryLastReceiptNo]![TaxReceiptNo])
and each provides the same result, which is #Name?
Am I correctly interpreting your suggesion?

ScottGem
Feb 21, 2012, 01:40 PM
Yes, but not implementing it properly. First a table doesn't have controlsources, so you must be referring to a form.

You needed to lookup the correct syntax for a DMAX. Thje syntax is:

DMax("[fieldname]","tablename")

So if TaxReceiptNo is your field and TblReceiptNumbers your table then use:

=DMax("[TaxReceiptNo]","TblReceiptNumbers")

as the controlsource. Or use:

=DLookup("[TaxReceiptNo]","qryLastReceiptNo")