Jump to content
Sign in to follow this  
Grax

Setting the Date?

Recommended Posts

Grax

I have two date fields in my GUI.

When the Primary Date is updated/changed, I need it to change the secondary to the same thing. I've tried:

GUICtrlSetData($Alarm_Date,GUICtrlRead($Call_Date))

But it doesn't update it. Ideas?

Thanks in Advance

Share this post


Link to post
Share on other sites
Grax

Post more code ...

$Call_Date = GUICtrlCreateDate("",235,50,100,20,$DTS_SHORTDATEFORMAT)

$Alarm_Date = GUICtrlCreateDate("",230,225,100,20,$DTS_SHORTDATEFORMAT)
GUICtrlSetState($Alarm_Date, $GUI_DISABLE)

Case $msg = $Call_Date
    GUICtrlSetData($AlarmNumber,_AlarmNumber(GUICtrlRead($Call_Date)))
    GUICtrlSetData($IncidentNumber,_IncidentNumber(GUICtrlRead($Call_Date),_AlarmNumber(GUICtrlRead($Call_Date))))
    GUICtrlSetData($Alarm_Date,GUICtrlRead($Call_Date))

Not sure what else you want the... This is what defines the variables and attempts to set it. Just an FYI enabling the $Alarm_Date doesn't change anything.

Andrew

Share this post


Link to post
Share on other sites
Grax

This code has nothing to do with setting the date, but here it is.

$Call_Date is passed to it, so it can figure out the current call number from the access db.

Andrew

Func _AlarmNumber($FuncDate)
    $oADO = _dbOpen($Database)
    $oRec = _dbOpenRecordset()
    $ToReturn = ""
    $FuncDate = StringRight($FuncDate,4)
    $oRec.Open("SELECT TOP 1 CallRecord_AlarmNumber,CallRecord_Date FROM CallRecord WHERE DATEPART('YYYY',CallRecord_Date)=" & $FuncDate & " ORDER BY CallRecord_Date DESC", $oADO)
    
    If $oRec.EOF Then
        If $FuncDate < 2008 Then
            MsgBox(0,"","I'm sorry the year of the Call Run Date is invalid")
            $ToReturn = 0
        Else
            $ToReturn = 1
        EndIf
    Else
        $LastCall = StringLeft($oRec("CallRecord_Date").Value,4)
        $ToReturn = $oRec("CallRecord_AlarmNumber").value + 1
    EndIf
    
    $oRec.Close
    $oADO.Close()
    Return $ToReturn
EndFunc

Share this post


Link to post
Share on other sites
ResNullius

I have two date fields in my GUI.

When the Primary Date is updated/changed, I need it to change the secondary to the same thing. I've tried:

GUICtrlSetData($Alarm_Date,GUICtrlRead($Call_Date))

But it doesn't update it. Ideas?

Thanks in Advance

Here's something using the DateTimePicker UDF

NOTE: this was thrown together based on my regional ShortDate settings of "dd/mm/YYYY"

#INCLUDE <DateTimeConstants.au3>
#Include <GuiConstants.au3>
#include <WinAPI.au3>
#include<GuiDateTimePicker.au3>
Global Const $WM_SETREDRAW = 0x000B
$Gui = GUICreate("Test")
$Call_Date = GUICtrlCreateDate("",235,50,100,20,$DTS_SHORTDATEFORMAT)
$Alarm_Date = GUICtrlCreateDate("",230,225,100,20,$DTS_SHORTDATEFORMAT)
GUICtrlSetState($Alarm_Date, $GUI_DISABLE)
GUISetState()

While 1
    $msg = GUIGetMsg()
Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $Call_Date
        ;GUICtrlSetData($AlarmNumber,_AlarmNumber(GUICtrlRead($Call_Date)))
        ;GUICtrlSetData($IncidentNumber,_IncidentNumber(GUICtrlRead($Call_Date),_AlarmNumber(GUICtrlRead($Call_Date))))
        _UpdateDate(GuiCtrlRead($Call_Date),$Alarm_Date)

EndSelect
WEnd

Func _UpdateDate($sDate,$DTPControl)
    $hDtp = ControlGetHandle($gui,"",$DTPControl)
    $aDate = StringSplit($sDate,"/")
    $tDate = DllStructCreate($tagDTPTIME)
        DllStructSetData($tDate, "Year", $aDate[3])
        DllStructSetData($tDate, "Month", $aDate[2])
        DllStructSetData($tDate, "Day", $aDate[1])
    _GUICtrlDTP_SetSystemTimeEx($hDTP, $tDate)
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.