Select to view content in your preferred language

How to store Time stamp for new point into DBF?

4090
7
09-14-2010 07:45 AM
AlexPhilippov
New Contributor
Hi ALL!

Hi ALL!

I tried string
<DATETIME defaultvalue="Now"...
in the form code, but param. value "Now" return date only.
What I must set to defaultvalue parameter to get time or may be date+time..?

Thx in advance!

R.,
--= APh =--
Tags (3)
0 Kudos
7 Replies
EricHajek1
Regular Contributor
I don't believe you'll be able to set the "defaultvalue" to anything useful in this case. I think you'll have to put something like this in the onload event of your form:

ThisEvent.Object.Pages("NAME OF PAGE YOUR CONTROL IS ON").Controls("NAME OF DATETIME CONTROL").value = Now

Hope this helps,
Eric
0 Kudos
AlexPhilippov
New Contributor
2 Eric:
Thanks for tip!
But if I put this code to onload="..." directly then it didn't work. (ArcPad load the standard form window instead of custom.)
If I try to put this code to external function and try to call this function from onload event (onload="Call getCurrentDateTime()" then I get an error message in VBScript "Objevt doesn't support this property or method: 'ThisEvent.Object.Pages'"... 😞

My code:
-------------------------------------------
poi.apl file
=================
<?xml version="1.0" encoding="UTF-8"?>
<ArcPad>
<LAYER name="poi" transparency="1">
<FORMS>
<EDITFORM caption="COLLECT POI! Tool" width="130" height="130" attributespagevisible="false" geographypagevisible="false" name="EDITFORM">
...
<PAGE name="Page4" caption="Contact" backgroundcolor="253,242,170" onload="Call getCurrentDateTime()" onvalidate="Call OnValidatePage2()">
...
<LABEL name="lbldate" x="2" y="115" width="30" height="10" caption="Today" tooltip="" border="false"/>
<DATETIME name="dtpDATE" x="40" y="113" width="90" height="13" tooltip="" tabstop="true" border="true" readonly="true" required="true" sip="false" field="DAT" allownulls="false"/>
</PAGE>
</EDITFORM>
</FORMS>
</LAYER>
<SCRIPT src="Poi.vbs"/>
</ArcPad>
=================

poi.vbs file
=================
Option Explicit

Sub getCurrentDateTime ()
ThisEvent.Object.Pages("Page4").Controls("dtpDate").value = Now
End Sub
...
=================
0 Kudos
EricHajek1
Regular Contributor
Hi,
It looks like the issue is that my code was intended for the form-level of the onload object, and you're loading it at the page-level.
In my code "ThisEvent.Object" refered to the form, since it was the form's onload event. However since you're already down to the page level "ThisEvent.Object" will refer to the page, meaning you don't need the ".Pages("PAGE4")" part of the statement.

Try:
ThisEvent.Object.Controls("dtpDate").value = Now

Good luck!
0 Kudos
RussellKallstrom
Occasional Contributor
Date and time fields are tricky in ArcPad.  Are you storing it in a date data type field, or a text field?  It might have something to do with that, as I've not been successful with date data types in ArcPad.  They seem only to come through as time or date, but not both in the same field, as you would expect by setting the variable to now().  I have always used a text field for that reason, to store the full UTC time in one field set the value = now().  I'm thinking your success will either be in using one text field (type 129, length 20) and setting it as I do or simply using two date fields.  Below is a two field example, called in the onsetactive event of the page.

Sub InitPage
   'Get a ref to the page
   Dim pCtrl, IDField
   IDField = "WEED_ID"
        Set pCtrl = ThisEvent.Object.Controls

     ' Increment ID number
          Dim objCurrLyrRS
          Set objCurrLyrRS = Layer.Records
          IF pCtrl("txtID").Value = "0" then
          pCtrl("txtID").Value = ReturnNextID (objCurrLyrRS, IDField)
          End if
  'Fill in Start Time / Date field with new Time if time hasn't been set.
   Dim curdatetime
                        If pCtrl("txtStartTime").Value = "" Then
    curdatetime = now()
    pCtrl("txtStartTime").Value = Cstr(FormatDateTime(curdatetime,3))
   End If
   If pCtrl("txtDate").Value = "" Then
    curdatetime = now()
    pCtrl("txtDate").Value = Cstr(FormatDateTime(curdatetime,2))
   End If
         Set pCtrl = Nothing
End Sub
0 Kudos
DanielBrenner
Regular Contributor
Russell and Eric,

I like what I'm reading here, because I am in the same boat, just trying to have the time and/or date show up on a form for Fire Weather Observations, and I have been going around in circles on this lately, because I have read both sides as to whether it is possible or not.

Could either one of you just lay it out, in terms of the steps from the creation of a field in a geodatabase in ArcGIS 10 to working with it in ArcPad 10 Studio, needed to do this?

Also, is it even remotely possible to have a date-time field in ArcPAD 10 or is it just safer to do Date in one field and Time in another?

Thank you,

Dan Brenner
Eureka, CA
0 Kudos
TroySpjute
Emerging Contributor
The wording here seems to be confusing.  The field itself CAN store date and time, however the actual form control can only store one or the other.  I am able to successfully set a field using a recordset to a date and time, but trying to set that to a control results in an error.
0 Kudos
WillLentz
Emerging Contributor
I have not tried this in v10 but in previous versions I accomplished this by making a text field with a default value of [now()] It records the complete date/time. When I get the data into Access I change the field type to a datetime and it works just fine.

ArcGIS 9x still ate the time off my datetime fields but ArcGIS 10 is supposed to be completely time aware so I don't know how it will work. I would try to capture data in a text field and when I bring it back into the desktop geodatabase make a new field and populate it from the txt.

Setting the default to now() is nice and simple, no coding.

Will
0 Kudos