captain1974
Registered User.
- Local time
- Tomorrow, 03:55
- Joined
- Jan 15, 2007
- Messages
- 43
Access 2003.
I have added an unbound textbox to my (sub)form which displays a value based on the value in another bound textbox.
This works ok, but when first loading the form it displays #Error. It also displays #Error when there is no subform data for the record selected on the main form.
The value I want to return is based on a function I wrote which returns a year value from a date. (Eg if the date is between 1/7/06 and 30/6/07, the year 2007 is returned). The function works fine, but I need to stop the #Error message when there is no data.
So far I have tried (unsuccessfully):
1. Placing the function within a Iif statement (directly in the textbox)
2. Changing the function to allow for a Null
3. Adding code to the afterupdate event of the textbox
Option 3 leaves the textbox blank, so I think I may wildly wrong with my code:
(Vintage is the name of my function, Text34 is the unbound textbox, the name of which will change if I get this to work)
Any ideas would be gratefully received.
I have added an unbound textbox to my (sub)form which displays a value based on the value in another bound textbox.
This works ok, but when first loading the form it displays #Error. It also displays #Error when there is no subform data for the record selected on the main form.
The value I want to return is based on a function I wrote which returns a year value from a date. (Eg if the date is between 1/7/06 and 30/6/07, the year 2007 is returned). The function works fine, but I need to stop the #Error message when there is no data.
So far I have tried (unsuccessfully):
1. Placing the function within a Iif statement (directly in the textbox)
2. Changing the function to allow for a Null
3. Adding code to the afterupdate event of the textbox
Option 3 leaves the textbox blank, so I think I may wildly wrong with my code:
Code:
Private Sub Text34_AfterUpdate(Vintage As Integer)
Me.[Text34] = Vintage(Me.EventDate)
Me.[Text34].Requery
End Sub
Any ideas would be gratefully received.