Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dlookup without a criteria 1

Status
Not open for further replies.

MICKI0220

IS-IT--Management
Jul 20, 2004
337
US
I have a lastmonthsnegative table. The month field all has the same month in it. I am trying to create a message box to warm the user that if they still need the information from that month they should not proceed. I was trying to use a dlookup to show what the month was in the table and notify the person in this message box. When I start the dlookup it wants a criteria. I really don't have a criteria because all the records in that temporary table will have the same month's value. How do I display this month in my message box?
 
It should not ask for a criteria. You must be typing it incorrectly. Please show your code.
The DLookup function returns a single field value based on the information specified in criteria. Although criteria is an optional argument, if you don't supply a value for criteria, the DLookup function returns a random value in the domain.

Thus if there is one record value in the table it will return that value record.
 
Dim varn As Variant
varn = DLookup("month", "lastmonthsnegative")
MsgBox "The previous month is: ", varn


Now I get an error message that says, "Type Mismatch
 
Both
Code:
dlookup("[month]", "[lastmonthsnegative]")
and
Code:
dlookup("month", "[lastmonthsnegative]")
worked in my tests against a table with one entry. And it consistently returned the first entry when I added more entries, but I wouldn't count on that result...

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
In my DLookup can I state that I want the first record? And if the answer is yes, how would I write it?
 
Have a look at the DFirst or DMin functions.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Why not simply add an id to your table and use it?

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
The table is recreated when I finalize the month out and create a new previous month field. This check is to make sure the month has not gone through it's finalization. By showing what the month is in the table at this moment it would warn the person from updating it again and screwing up the information.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top