[SOLVED] Auto populate date/time in a field - not working???

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

[SOLVED] Auto populate date/time in a field - not working???

Post by karmacomposer » Fri Jul 20, 2018 3:19 am

I can't figure out why this does not work?

It's supposed to pre-populate a field with the current date/time

Code: Select all

on preOpenCard
   put the long date into varNowDate
   set the text of field "fldDateAllottStart" to varNowDate
end preOpenCard
I am using the variable varNowDate because I need to write that variable to a database later.

I have this in the card script.

Mike
Last edited by karmacomposer on Fri Jul 20, 2018 4:18 am, edited 1 time in total.

ClipArtGuy
Posts: 205
Joined: Wed Aug 19, 2015 4:29 pm

Re: Auto populate date/time in a field - not working???

Post by ClipArtGuy » Fri Jul 20, 2018 3:31 am

Code: Select all

on preOpenCard
   put the long date into varNowDate
   put varNowDate into fld "fldDateAllottStart" 
end preOpenCard
This is working here.

karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

Re: Auto populate date/time in a field - not working???

Post by karmacomposer » Fri Jul 20, 2018 3:35 am

I will say that the field mentioned is part of a group of controls - could that be it? It's simply not working for me.

Mike

ClipArtGuy
Posts: 205
Joined: Wed Aug 19, 2015 4:29 pm

Re: Auto populate date/time in a field - not working???ou may

Post by ClipArtGuy » Fri Jul 20, 2018 3:38 am

Did you try the Put statement that I replaced your "set the text" line? If that's not working you might need to do something like :

Code: Select all

put varNowDate into fld "fldDateAllottStart" of grp "yourgroup" of cd "yourcard"

karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

Re: Auto populate date/time in a field - not working???

Post by karmacomposer » Fri Jul 20, 2018 3:43 am

Should I put this in the card or stack script?

So weird - it's simply not populating that field.

Yes, I did check the properties, font and color to make sure it's not set to invisible or white on white.

Mike

ClipArtGuy
Posts: 205
Joined: Wed Aug 19, 2015 4:29 pm

Re: Auto populate date/time in a field - not working???

Post by ClipArtGuy » Fri Jul 20, 2018 3:56 am

If you want it to happen every time a card is opened, then put it into the stack script. If you want it only on one card, put it into that card's script.

karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

Re: Auto populate date/time in a field - not working???

Post by karmacomposer » Fri Jul 20, 2018 4:07 am

OK. Very weird - I even tried a new text box field and it still did not work.

What would be a way to get the current date and time to auto populate a field? Which control should I use?

Mike

karmacomposer
Posts: 256
Joined: Wed Apr 27, 2011 2:12 pm

Re: Auto populate date/time in a field - not working???

Post by karmacomposer » Fri Jul 20, 2018 4:18 am

I got it working by attaching it to a necessary button to write to the database - not really what I wanted but it works and it's automatic.

Mike

Post Reply

Return to “Talking LiveCode”