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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text box - formula to test against values for what to display

Status
Not open for further replies.

datsyuk

Programmer
Jun 15, 2012
5
0
0
US
I have a text box and what I hope to accomplish is test if a value (the current date) is equal to any of the value in a table and if it is equal to a value in the table then display the associated value with that value. So to be more clear. I have a text box. I want to test the current date off of a table that contains a list of dates and an associated number relating to that date. I want to display this number. I have accomplished this using a query subform; however as I am going to have multiple instances differing slightly I would rather take the text box route if possible.

As i am more familiar with C to help explain written in C it would be:

for(i=0; i<dateListEnd; i++)
{
if (dateList=currentDate)
{
cout<<dateValue;
}
}

I am just starting in VBA and not very familiar with it. I know I will need an iff statement (using Date() and Month()) to compare the two and the return value will be the associated value of whichever date matches.
So again, the structure that I am looking for is something like this:

for all entries in the table if date is equal to current date display associated value. There will only ever be one value in the table that is equal.

THANKS!
 
I think all you might need is
Code:
=DLookup("YourField","YourTableName","YourDateField = Date()")

Consider providing actual table and field names, sample data, and desired output.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top