Macro to capture the current time for a bound filed in a form.

C

CRC

I am trying to use the setValue function to have a button command to capture
the current time for the field name RunStartTime bound to the Form. Can
anyone tell why what I have coded is not working.

--------Here is the code-------------------------------------------
Private Sub GetTime_Click()
On Error GoTo GetTime_Click_Err

' Capture current time for Run Start Time.
Forms![TestStation]!RunStartTime.BeforeUpdate = Time()


GetTime_Click_Exit:
Exit Sub

GetTime_Click_Err:
MsgBox Error$
Resume GetTime_Click_Exit

End Sub
---------------------------------------------------
 
S

Steve Schapel

CRC,

I can't quite understand your question, as there is nothing there about
SetValue. In fact, SetValue is a macro action, whereas what you have showed
us is a VBA porocedure, which does not have a SetValue method as such, and
has nothing to do with macros.

Nevertheless, you can certainly achieve your purpose using the approach you
have taken. The problem being with the reference to "BeforeUpdate", which I
am not sure why that is there.

Assuming the GetTime command button is on the same form TestStation as the
RunStartTime control, try it like this:

Me.RunStartTime = Time
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top