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!

If Null, then I want the Current Date to be entered...

Status
Not open for further replies.

JonWolgamuth

Technical User
Apr 19, 2001
53
US
I have a form where the user looks up items entered into the database. I want them to enter information, choose a button which says "Mark Completed", and have Access assign today's date and time to the table--unless the item has already been marked as completed. It would be nice if the form could ask the user "Already marked completed. Reset completed date to today's date?" or something like that.

I'm a little familiar with some VB, but I'm very much a novice. I'm sure it will be done with code under the OnClick section, but...

Alms for a VB novice?

TIA!

Jon
 
There are at least a couple of ways to do this. The novice one that comes to mind is to simply place a couple of controls bound to the fields you want to be auto-updated when a user clicks a certain button. These bound controls you can make hidden on the form. When the user clicks the 'Mark Completed', then use something like the below code...

If Me.chkComplete then
msgbox "This item is already marked as complete. Reset?"
else
me.chkComplete = True
Me.txtCompleteDate = Now()
msgbox "Item is now completed!"
End if

Gary
gwinn7
 
Jon:

Another approach, if the form is used only to enter information related to the completion, would be to filter the forms underlying recordset to exclude any records with an entry in the Date Completed field. In this way, the user sees only those records that require completion.

Or, if you want them to see all records but only be able to edit those that have not yet been completed, lock all the fields (except the selection control) when the form opens. Add a command button called "Edit" and in that button's On_Click event test the contents of the date field. If it has been completed, display a message to the user that the record is complete and then exit the sub. If the date is empty (null) then "Unlock" the editable controls to allow the user to add the new data. You could also put the command here to set the date to today using a simple command of CompletionDate = Date().

I would also put a Save command button on the form to explicity save the changes the user makes and to also re-lock all fields.

This may sound too complex for a novice but is actually pretty easy to implement. If you would like some sample code, send me an e-mail.

Good luck.
Larry De Laruelle
larry1de@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top