#Error in form control until user input

domtrump

Board Regular
Joined
Apr 1, 2010
Messages
245
I have a control on a form defined with the following formula:

=[Date]+Choose(Weekday([Date]),5,4,3,7,6,5,6)

It takes the user enters a date into the [Date] field and this field calculates the due date for a project. The control works fine, however, when you go to add a new record, the control displays #Error until the user enters a date.

This is just cosmetic, but how can I make this control just be blank until the user enters the date?

Thanks.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I have a control on a form defined with the following formula:

=[Date]+Choose(Weekday([Date]),5,4,3,7,6,5,6)

It takes the user enters a date into the [Date] field and this field calculates the due date for a project. The control works fine, however, when you go to add a new record, the control displays #Error until the user enters a date.

This is just cosmetic, but how can I make this control just be blank until the user enters the date?

Thanks.

=IIf(IsNull([Date]), "", [Date]+Choose(Weekday([Date]),5,4,3,7,6,5,6))

but also just an FYI - you should not use DATE for the name of a field. It is an Access Reserved Word and can cause major pain and suffering when dealing with it as such.
 
Upvote 0
Just check if the other control has a value in it.

Not sure what the other control is called though, you just seem to be referring to the Access funtion Date in that expression.
 
Upvote 0
=IIf(IsNull([Date]), "", [Date]+Choose(Weekday([Date]),5,4,3,7,6,5,6))

but also just an FYI - you should not use DATE for the name of a field. It is an Access Reserved Word and can cause major pain and suffering when dealing with it as such.

Thanks. That worked great. I was checking if it was ="" but I guess IsNull is the way to go. (Oh, and that isn't the real name of the field but thanks for heads up :)
 
Upvote 0
Date fields don't have empty strings "" so you can't check for those. Dates are either null or have a value. But if you have a text field where it could be EITHER null or an empty string then a good check is this:

IIF(Len([FieldNameHere] & "") = 0, "", "Something")
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,894
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top