Home

Cardbox Talk

 

CardboxForumsCardbox Talk > "Drop down calendars"

Drop down calendars

Calendars

Current user: [none]
Register / Log In · Help

Posted By Post

databaseuser

27-Apr-2009 14:57

I have recently downloaded a trial copy of Cardbox to see if it is suitable for our needs. The database we plan would involve the imput of a number of dates. In cardbox is there a facility where I can click on a field and a drop down calendar appears and I can simply click on a specific date and this will be inserted in the field. Your help would be appreciated

Charles Welling

28-Apr-2009 08:45

No, there's no such calendar, but I too needed one, so I made it myself using AutoIt3.

There are two small executables, Longdate.exe and Shortdate.exe. When started they give you a calendar in either the shortdate or the longdate format, according to your local date settings.
On clicking OK, the chosen date is copied to the Windows clipboard. You could use a small macro to start the executable and then type your date into a field. Example:

run "C:\Cardbox3\Longdate.exe"
TypeText Clipboardtext

which enters the date as if it were typed from the keyboard, or

run "C:\Cardbox3\Longdate.exe"
Fields("DATE")=Clipboardtext

which replaces anything in the field "DATE" by the chosen date.

You may download the executables from "avs.hmr.rotterdam.nl/cardbox".
No spyware :-)

databaseuser

28-Apr-2009 13:23

Thanks to Charles Welling I have managed to get the above Macro to insert a date in a single field. My next problem is how to use this facility to get the macro to insert different dates in two or more fields using a single macro. Is this possible or do I have to create a macro for each field. Thank you for your assistance.

SJSeager

28-Apr-2009 14:40

The calendar from Charles is a neat little script.
However, if you want to modify it a little, one can be done in HTML - easy to tweak then.
Save the below as a HTA file, say Calendar.hta

<HTML>
<HEAD>
<TITLE>Show Date Calendar</TITLE>
<HTA:APPLICATION
     ID="HTACalendarControl"
     APPLICATIONNAME="HTACalCtrl"
     SCROLL="no"
     SINGLEINSTANCE="no"
     WINDOWSTATE="normal"
>
<script language="VBScript">
Sub Window_Onload
 self.ResizeTo 350,300 'w,h
 self.MoveTo 1,1
End Sub
Sub ShowDate
' MsgBox Calendar1.Value
' Copy to clipboard
' Me.clipboarddata.setdata "Text", Cstr(Calendar1.Value)
' or
' Copy to Cardbox scrap variable
 Set ocbx = GetObject(,"CardBox.Application")
 ocbx.Scrap(70) = Calendar1.Value
 Set ocbx = Nothing
Me.Close
End Sub

</SCRIPT>
</HEAD>
<body STYLE="filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#0000AA', EndColorStr='#000055')">
<p align="center">
<OBJECT CLASSID="clsid:8E27C92B-1264-101C-8A2F-040224009C02" id="Calendar1"></OBJECT></p>
<p align="center">
<input type="button" name="OKButton" value="Show Date" onclick="Set Date">&nbsp;&nbsp;&nbsp;
</p>
</BODY>
</HTML>

Now create a Cardbox macro file, called Calendar.cbs

     Run "m:\testcal3.hta"
     EditRecord
     GoToField commandline
     Command cmdSelectAll
     TypeText Scrap(70)
     SaveRecord

Now in your database add a pushbutton next to the field that you want a calendar.
We need to add a reference to the macro as well as the field that it is going to modify.
In macro name, under the action section, put in Calendar,'fieldname' where fieldname is the name of your field where you want to date result to be shown.

Notes.
The HTA file only works under Internet Explorer.
I use a cardbox scrap variable called Scrap(70) to store the result from the HTA file.
These so called scrap variables are very useful when used in conjunction with the cardbox command line.
Lookup scrap variables and command line in the cardbox help to understand these a little more.

SJSeager

28-Apr-2009 14:42

Spot the mistake seconds after posting..... ooops.
In the Cardbox macro file the line
 Run "m:\testcal3.hta"

Should read Run "path_to\Calendar.hta" - with the path modified to point to the right place.

Charles Welling

29-Apr-2009 10:18

Replace
"Fields("DATE")=Clipboardtext"
by
"ActiveField=Clipboardtext"

The macro will then insert the date in the active field, i.e. where the cursor is.

And as far as my little script is concerned: it can be decompiled and modified or anyone can write his/her own script using AutoIt3, which is a free VBscript-like scripting language with quite a few interesting features (www.autoit3.com).
If anyone is interested: the source of the scripts (they are very short) is now available too (avs.hmr.rotterdam.nl/cardbox). They can be viewed and edited with Notepad, but you'll need AutoIt3 to execute and/or compile them.

bert

29-Apr-2009 12:26

Hi SJ Seager,

Line34 of your schript line must be changed to:
<input type="button" name="OKButton" value="Show Date" onclick="ShowDate">&nbsp;&nbsp;&nbsp;

Any kind of solution generated by an .exe file, Windows gives boaring messages in networksituations. So your solution is really a nice solution. IE is is always in Windows (how long will that be...), HTA files are default attached to IE, so it will always run on any windows platform.
The format of the generated date can be modified in the Cardbox macro using the DateToCardbox function.

Regards
Bert

Charles Welling

29-Apr-2009 14:34

"Any kind of solution generated by an .exe file, Windows gives boaring messages in networksituations" ???

Could you please explain this remark? People who read this forum should not be exposed to such unfounded opinions. My solution is used across a network, and does not generate boring messages, or in fact any message at all. It is a simple, fast "out of the box" solution for anyone who needs a calendar. It pops up, disappears and leaves the chosen date on the Clipboard, so it works in any other application beside Cardbox.

Mary Doyle (DAF)

29-Apr-2009 15:28

Hi Charles and all,

Whatever about messages (boring or otherwise), exe files do often create problems in network situations as they may not, for starters, be authorised by the network manager. However, I am in the fortunate situation that we have been able to use your autoit calendar and find it very useful using, as you suggest, ActiveField, so that it works with any field. I was unable to access the source code, as you suggested above, though I would be interested to see it.

I will look with interest at the HTA version described above as well, out of interest. I do know from experience with a HTA form I was experimenting with to search Cardbox databases that HTA forms can give rise to security messages. This can apply with stand-alone PCs as well as networks depending on the PC's security settings.

Regards
Mary

Mary Doyle (DAF)

29-Apr-2009 16:18

Just for the record this is the macro we use - we store it as a General Macro accessible from all databases and workspaces.
Launch "...path\shortdate.exe"
Pause "Continue macro when date chosen"
ActiveField = ClipboardText

It is really simple and effective. Charles made shortdate.exe available in an earlier post, which was much appreciated by me, anyway. I was going to alert the original enquiry to this posting to that earlier reply, but I was beaten to it!

bert

29-Apr-2009 17:56

Charles,

If you launch in a macro an .exe which is on a share + using UNC path (a lot of situations are drives not mapped), Windows asks "is it allright, is it trusted" and so on.
Not so nice in such a macro. I met this often, so, that is why do not prefer to launch .exe file in that kind of macros.
Although I understand the meaning of this Windows messages, I find that type of messages of Windows boaring. The more it is no easy to get rid of this.
Regards
Bert

Charles Welling

30-Apr-2009 07:52

And to conclude this discussion:

This exe has never generated any messages, and it has been used on WIN2000, XP, Vista and WIN2003. It is simply executed, even using UNC paths. However, the Cardbox database must be opened in the "Completely trusted" mode.

And Mary: the source code is in "avs.hmr.rotterdam.nl/cardbox" (shortdate.au3 and longdate.au3). You're obviously an ardent programmer, so you really should download AutoIt3 if you haven't already. Even if you you don't really use it, it's fun to play with.

By the way, don't bother downloading the source. Here it is:

#include <GuiConstants.au3>
ClipPut("")
GuiCreate("Cardbox date selection", 250, 150)
GuiCtrlCreateLabel("Pick a date:", 5, 10)
$datum=GuiCtrlCreateDate("", 5, 50, 200, 20,"LOCALE_SSHORTDATE")
$okbutton = GUICtrlCreateButton ("OK",5,90,70,20)
GUICtrlSetState ( $okbutton, $GUI_FOCUS )
$cancelbutton = GUICtrlCreateButton ("Cancel",90,90,70,20)
GuiSetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton
ExitLoop
Case $msg = $okbutton
ClipPut(GUICtrlRead($datum))
ExitLoop
EndSelect
Wend
GUIDelete()
Exit

bert

30-Apr-2009 08:44

Hi Charles,
In many situations it is not allowed by policy of system administrators for users to install programs on their system like AutoIt3. So that is why I prefer solutions which can run in a standard Windows situation. And if VB Script/Cardbox macro language can give you wished result, why use something else?.

That your script does not generate messages is normal. It is like opening a file using a program (doc in Word, fil in Cardbox).

Regards
Bert

greenkeeper

3-Aug-2015 16:42

Can anyone help with this ??

I appreciate this is an old post, but am having a little trouble with implementing it....

I couldnt get the link on here thathas Charles' exe - its an old link! so...

I have built the calendar in HTML

I have run a macro to the path on my desktop...

This is the bit im having trouble with.....

Now in your database add a pushbutton next to the field that you want a calendar.
We need to add a reference to the macro as well as the field that it is going to modify.
In macro name, under the action section, put in Calendar,'fieldname' where fieldname is the name of your field where you want to date result to be shown.
Notes.
The HTA file only works under Internet Explorer.
I use a cardbox scrap variable called Scrap(70) to store the result from the HTA file.
These so called scrap variables are very useful when used in conjunction with the cardbox command line.
Lookup scrap variables and command line in the cardbox help to understand these a little more.

It works, but it saves to the same field every time, I have tried changing the 'fieldname' under the action section, but to no avail - I am stuck!!
I am not good at writing macro's generally get there through trial and error, but struggling with this... It may just be the way I am writing it?

Olly

bert

3-Aug-2015 20:10

First: Please send your macro to cardbox@outlook.com. Second: write what the macro must do. Something as: I want a screenbutton which starts a macro. That macro shows a calender, then the choosen dat must be inserted in field xxx.
I can see what I can do for you.
Regards
Bert

bert

6-Aug-2015 09:48

Hi Olly,
I do not see something in the mail. Problem solved?
Regards
Bert

Charles Welling

6-Aug-2015 11:58

The calendars are back. You can download them at:

http://download.atlasvanstolk.nl/cardbox

bert

6-Aug-2015 12:33

If I understood it right, it handled about a hta application.

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home