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

Invalid use of Property: Please take a look 1

Status
Not open for further replies.

BillMc

Programmer
Dec 8, 2000
45
US
I want the YRID field to be updated to the current year Year(Date) if the field is blank. If the field has been filled in with let's say next year's date, then I want it to be unchanged.

My formula is as follows:

[tt]Private Sub VehicleID_Exit(Cancel As Integer)

If Forms!ORPInsForm!YrID > 1 Then YrID
Else: YrID = Year(Date)
End Sub[/tt]

The error message reads:
Invalid use of property

It appears as thought the YRID field property needs to be changed. Currently it's data type is a NUMBER the format is FIXED and decimal places set a O. Any suggestions to make this work?

Thanks, Bill
 
Your syntax is not correct. Re-write it as :

If Forms!ORPInsForm!YrID > 1 Then
Forms!ORPInsForm!YrID = YrID
Else
YrID = Year(Date)
End If
End Sub

HTH
Lightning
 
Your error message is probably due to the Number type not accepting a null value. Try changing your code to the following:

If Val(Forms!ORPInsForm!YrID & " ")> 1 Then
'YrID 'nothing should happen here!
Else
YrID = Year(Date)
end if
End Sub

This I have had a lot of problems with Access Tables that allow null values when I try to assign them to mumeric variables, and this is a working solution that is easy to implement.

Hunter
 
Lightning,
That worked. Thanks for taking the time to solve my problem.

Hunter,
I appreciate your input. Thanks, Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top