calendar popup on doubleclick

rbarrett

New member
Local time
Today, 17:40
Joined
Jun 18, 2001
Messages
8
Is it possible to copy the value of a control to clipboard and then paste it into another control using vba? What I am trying to do is create a "calendar on double click". I am using the activeX calendar. In the date field on my form I have the double click set up to bring up a popup of the calendar then I have the calendar set to copy the value after update and close but I am getting an error that says the copy cmd cannot be run right now and it tells me that I need to either convert the db (running 2000) or it is in a read only mode (sure it is!!). When I get back to the main form I have the date field set to paste the value of the calendar control (this is as of yet untested). Is there an easier way to do what I want without having to go through all this. Or can you tell me what is wrong with this code.

Private Sub
frmCalendar_AfterUpdate()
DoCmd.GoToControl "calendar"
DoCmd.RunCommand acCmdCopy
DoCmd.Close acForm, "frmCalendar"
End Sub
 
i had similiar trouble with the calendar control and trying to copy date values. i found that the control had to have focus (once again an annoyance) before i could copy its value.
here`s the sub that i`ve used to complete this task.
--------
Private Sub GoBack_Click()
On Error GoTo Err_GoBack_Click
'Dim stDocName As String
Dim StartDate, EndDate As Date

StartDate = FromCalendar.Value
EndDate = ToCalendar.Value

If StartDate > EndDate Then
MsgBox "Your 'To Date' is earlier than your 'From Date'!" & Chr(10) & _
"Please select new dates.", vbCritical + vbOKOnly, "Warning!"
FromCalendar.SetFocus
FromCalendar.Today
ToCalendar.SetFocus
ToCalendar.Value = Date + 6
GoTo Exit_GoBack_Click
Else
If Forms!frmfindcriteria!FromDate = StartDate And _
Forms!frmfindcriteria!ToDate = EndDate Then
Else
Forms!frmfindcriteria!PeriodLookup = Null
Forms!frmfindcriteria!FromDate.Value = StartDate
Forms!frmfindcriteria!ToDate.Value = EndDate
End If
DoCmd.Close acForm, "frmSelectDates", acSavePrompt
Forms!frmfindcriteria!Preview.SetFocus
End If

Exit_GoBack_Click:
Exit Sub

Err_GoBack_Click:
MsgBox Err.Description
Resume Exit_GoBack_Click

End Sub
---------
also, if your date values may not be in the correct data form, try using the function CDATE.
i used it as follows:
StartDate = CDate(PeriodLookup.Column(1))
EndDate = CDate(PeriodLookup.Column(2))

hope this helps!
 

Users who are viewing this thread

Back
Top Bottom