Refernce to a field
Posted on 2014-02-05
I am using the below code that is working great (thanks to your guys help). The issue is when it references the "Me.DateRecorded", it works if I have that actual field on the form. I would rather not have that in the field. The form is a subform of another that lists the DateRecorded. It is redundant (and space consuming) to have that value listed twice.
The value comes from a query titled "Booking Details Extended". The parent form that it is a subform of is titles "Bookings subform" (that is because it is still a subform to another main form). In essance, there are 3 levels of subforms.
Can I reference that date field without putting it on my actual form?
Private Sub ItemPrice_BeforeUpdate(Cancel As Integer)
Dim strCorrectPassword As String
strCorrectPassword = Abs(Me.BookNumber - 1111) * 2
If Me.DateRecorded < Date - 1 Then 'Reads in a date field on your from called "Some Date"
If InputBox("Enter Password") <> strCorrectPassword Then 'Compares passwords
Cancel = True
MsgBox "Change not allowed without valid password.", vbOKOnly
Me.ItemPrice.Undo 'undo recent change to this field