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

set all fields in a database to todays date if double click

Status
Not open for further replies.

kazprog

Programmer
Jan 28, 2004
11
GB
Hello
Does anybody know how to set any field in a database to todays date if they press double click on a form ?

I have set an event that on double click does the following

Private Sub Text7785_DblClick(Cancel As Integer)
Me![Job Received] = Date
End Sub

Is there a macro or vb module I can set up that can be called to prevent this needing to be entered for all fields on all forms in the database?


 
I cannot quite beielve that you mean all columns of all tables, but a variation on

Private Sub Text7785_DblClick(Cancel As Integer)
Dim strSQL as String
'
strSQL = "UPDATE MyTable SET [Job Received] = #" & Format(Date(),"yyyy/mm/dd") & "#;"
docmd.runsql strSQL
End Sub

a visit to help to read up on the SQL UPDATE statement and the DOCmd.RunSQL statement should allow you to adjust the above code to fit your needs


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I want any field that the user double clicks on a form to default to todays date without having to do VB code for each double click event on each form.
 
Hi

Do not see how you can avoid having cod ein double click of each control, how will you know which control was clicked on?

You could have a general purpose routine (probably) using ActiveControl property to tell you which control was clicked on

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
kazprog

Like Ken, I am puzzled on your exact requirements, but here are a couple of things.

First,
Code:
 I want any field that the user double clicks on a form to default to todays date without having to do VB code for each double click event on each form.

I suspect you mean any "date" field defaults to the current date, not "any field".

Next, Do you realize that you can set a date field to use the current date. This propery can be set either in the form or the when defining the table definitions. For default value have something like...
=Date()

You have already explored the simple coding event procedure. This can be supplemented to run code that updates relevent fields on the form or child records. Ken has started you on one solution for this idea.

Richard



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top