Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 938
  • Last Modified:

VB 6.0 raising the event closeup

I am trying to close the calendar view on the DTPicker obejct once the desired date has been achived.

How can I do this?
0
ExtremeFitness
Asked:
ExtremeFitness
  • 4
  • 4
1 Solution
 
mvidasCommented:
Hi ExtremeFitness,

Can you explain a little more what you mean? The _CloseUp event is fired when a date is chosen on the calendar view, and only the chosen date should remain in the calendar view. I guess I should ask what you mean by "desired date has been achieved"?

Matt
0
 
ExtremeFitnessAuthor Commented:
mvidas,
When the user clicks on the month change, I check to see if 4 months were added to the original date.  Once this happens, I wish to close the calendar view.
EF
0
 
mvidasCommented:
EF,

I understand now, sorry about that wasn't quite sure.

I've tried a variety of ways of doing this in the past, and the final method really depends on what you want to be left after closing the calendar mode.

Do you want the original date returned as the value? If so, then use SendKeys with escape:

Dim DTInitVal As Variant

Private Sub DTPicker1_DropDown()
 DTInitVal = DTPicker1.Value
End Sub

Private Sub DTPicker1_Change()
 If DateAdd("m", 4, DateSerial(Year(DTInitVal), Month(DTInitVal), 1)) <= _
  DTPicker1.Value Then SendKeys "{ESC}"
End Sub


However, if you want the "original date + 4 months" as the value, make .visible=false then .visible=true:

Private Sub DTPicker1_Change()
 If DateAdd("m", 4, DateSerial(Year(DTInitVal), Month(DTInitVal), 1)) <= _
   DTPicker1.Value Then
  DTPicker1.Visible = False
  DTPicker1.Visible = True
 End If
End Sub

Matt
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ExtremeFitnessAuthor Commented:
Matt,
I have no issue figuring out the datediff, it is 'minimizing' the calendar of the object.
I have tried the SendKeys, but did not work.
Avri
My code
If DateDiff("m", dtStart, dtpExpireDate) > 4 Then
           
           
            MsgBox "Maximum of 4 Month Time Credit Allowed", vbInformation
            dtpExpireDate.value = DateAdd("m", 4, dtStart)
            dtpExpireDate.Refresh
           
            btnSave.Enabled = DateDiff("m", dtStart, dtpExpireDate) > 0
            SendKeys "{ESC}"
 
            DoEvents
            Exit Sub
    End If

0
 
mvidasCommented:
Strange that it isn't working like this, even with a ", True" after the escape send. I've never been a big fan of sendkeys anyways, though there are cases like the dtpicker where it is useful (though obviously buggy).  In this case, just make it invisible then visible:


    If DateDiff("m", dtStart, dtpExpireDate) > 4 Then
            MsgBox "Maximum of 4 Month Time Credit Allowed", vbInformation
           
            dtpExpireDate.Value = DateAdd("m", 4, dtStart)
            dtpExpireDate.Visible = False
            dtpExpireDate.Visible = True
           
            btnSave.Enabled = DateDiff("m", dtStart, dtpExpireDate) > 0
 
            DoEvents
            Exit Sub
    End If

Seems to me you could just enable btnSave in there without the datediff function, but I'm guessing you have your reasons.

Matt
0
 
ExtremeFitnessAuthor Commented:
Matt,
Sorry, no dice....
I event placed a doevents in betweens

             dtpExpireDate.Value = DateAdd("m", 4, dtStart)
            dtpExpireDate.Visible = False
            doevents
            dtpExpireDate.Visible = True
            doevents

Thanks about the enabling of the btnSave, done that twice.
Avri
0
 
mvidasCommented:
Hi Avri,

Strange, that worked for me (though it was just a simple form with a DTPicker named dtpExpireDate and the button, I still just copied/pasted from dtpExpireDate_Change in the form's module). Just a thought, maybe you could try repainting the form?

            dtpExpireDate.Value = DateAdd("m", 4, dtStart)
            dtpExpireDate.Visible = False
            dtpExpireDate.Visible = True
            Me.Repaint

If not, I'm not sure what else I could suggest..
Matt
0
 
EDDYKTCommented:
can you do

Me.SetFocus
DTPicker1.SetFocus
0
 
ExtremeFitnessAuthor Commented:
I'm done... decided to ignore the issue.  
The software will retire in five months.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now