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

Date update question (it works one way )

Status
Not open for further replies.

julius1

Technical User
Oct 31, 2002
142
US
I have a form and a macro set up to update the date in another field once it becomes checked to show it as occupied. It is set up as an after update event macro with set value to date()
That works fine, my problem now is if the item is vacant and the check is removed, how can I get the date to go away?
Is there away to update it to remove the date from the table?

I plan on creating a report that will list the last three dates in the series of occupancies, most of the series is a total of 24, if any of the channels are occupied, then the date will appear showing the date it was occupied, but if it is now vacated, and the check is removed, I no longer want the date to appear on the report for the channel.
 
The easiest way is to use some code in the AfterUpdate event and get rid of the Macro. To do this you click on the line next to the AfterUpdate event. You will see a little button with three dots ... (elipsis is think it's called) Click on that button and then select Code Builder from the list. This will give you an AfterUpdate even for your Checkbox. Then in the code put

If Me.CheckBoxName = True Then 'or -1 if you want
Me.DateField = Date()
Else
Me.DateField = False
End If

That should do it.

Paul
 
Sorry, the second half after the Else statement should be

Me.DateField = Null


Paul
 
I loaded this into the code sction.
Private Sub Vacant__AfterUpdate()
If Me.Vacant = True Then 'or -1 if you want
Me.Dateocuupied = Date
Else
Me.Dateocuupied = Null
Me.Dateocuupied = False
End If
End Sub


I get a compile error telling me method or data member not found. I have tried changing the names in the tables and forms but still get the same error.
 
Try it without the Me.Dateoccupied = False line

You can't set a date value to False.

Paul
 
Still didnt work, I think I can modify my query for the report to exclude those vacant, which would eliminate the date issue. I tried to over wrtie the date as if I added a new circuit to the list on that same channel and it took the current date. I think if I do that I should be ok
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top