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

help with control source

Status
Not open for further replies.

davyre

Programmer
Oct 3, 2012
197
AU
Hi,
I have 2 textboxes on a report named CUDD(Customer UDD) and CDate, and in the CDate control source I put code:
Code:
=Nz([CUDD],DateAdd("d",30,[CUDD]))

basically it looks for CUDD textbox, if it has a value then show CDate its value, if CUDD empty then I want to show date+30 days to CDate textbox. But it does not show any value if CUDD is blank. I did not receive any error for the code. Any help?

and also, can I change background color of CDate textbox if CUDD is empty? what is the code for that? Thanks
 
First, avoid using functions names as control or field names. CDate is a function.

You are adding CUDD is null, you are adding 30 days to CUDD which is Null. This makes no sense.

Duane
Hook'D on Access
MS Access MVP
 
yeah, maybe I was out of focus this morning. I have found that CUDD is null and trying to add 30 days which is stupid. My bad.
But then we come to the second question, how to change the textbox background color?
I changed the code to

=IIf([CUDD] Is Null,DateAdd("d",30,[CustOrderDate]),[CUDD])

and not sure what to add in the middle to change the textbox color. I tried to use CustUDD.BackColor=vbYellow but it does not work (a parameter dialog box appeared).

*note that I changed the CDate name to CustUDD.
 
You can probably simplify your expression to:

Code:
=Nz([CUDD],DateAdd("d",30,[CustOrderDate]))

You can't add anything to the expression to make it change color. Use Conditional Formatting of the text box.

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

Part and Inventory Search

Sponsor

Back
Top