Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 1st, 2004, 05:35 PM
Registered User
 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting date from Calendar 9 into a new record

I have a table with a date field, a form for entering data to create a new record in the table, and a form containing Calendar 9.0 with a button to return the data entry form. There is a VBA module for the OnClick form event in the date field that launches the calendar form. I can select month, year, and date in the calendar form without a problem.

Problem: The date selected in the calendar form does not appear in the data entry form. (I also have a form for editing an existing record, the date appears there fine from the calendar form.)

Question: How does one get the date from the ActiveX Calendar into the form so that it will be added to the database when the record is saved?

 
Old November 1st, 2004, 07:14 PM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you have one form that works, then how are you passing the date back in that case? It sounds like you have a separate form with an embedded calendar control that you pop open. You need to pass that form a parameter - perhaps in OpenArgs - so it knows where to stick the selected value when the user picks one.


John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
 
Old November 8th, 2004, 02:13 PM
Registered User
 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is an example of the vb code I've worked with. If you need more than what I have pasted here, let me know?

Option Explicit
Dim cboOriginator As ComboBox



Private Sub ocxCalendar_Click()
cboOriginator.Value = ocxCalendar.Value
cboOriginator.SetFocus
ocxCalendar.Visible = False
Set cboOriginator = Nothing
End Sub


Private Sub ComboButton1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Set cboOriginator = EvaluationDueDate
    ocxCalendar.Visible = True
    ocxCalendar.SetFocus
        If Not IsNull(cboOriginator) Then
            ocxCalendar.Value = cboOriginator.Value
        Else
             ocxCalendar.Value = EvaluationDueDate
        End If



End Sub


 
Old November 8th, 2004, 03:52 PM
Authorized User
 
Join Date: Sep 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It sounds like you have a separate form that contains the calendar. This sounds as much a form design issue as it is a programming issue. You may want to consider placing the calendar into the same form as the field you want to place the date in, then you will not have to worry about passing arguments. Why pass arguments if you don't need to? After placing the calendar in the other form, use the code that you used in the edit form. Or go to the Visual Basic Editor and bring up your Calendar under the Object Combo Box then go the Click Event in the Procedure Combo Box. The reason you can not do an OnClick Event from the Calendar property is because it does not allow an OnClick Event from the Properties Window - How Peculiar; however, you can get the OnClick Event in the VB Editor. The following one liner will do it: Me.Date(or name of your field).Value = Me.Calendar1(or the exact name of your Calendar9 control).Value

Again - Me.Date.Value = Me.Calendar1.value

Hope this works.

David

 
Old November 8th, 2004, 11:24 PM
Authorized User
 
Join Date: Sep 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I am responding to your post for a second time, because I'm not sure it was distributed. It never came back to me. If you get it a second time, please pardon me.

It sounds like you have a separate form that contains the calendar. This sounds as much a form design issue as it is a programming issue. You may want to consider placing the calendar into the same form as the field you want to place the date in, then you will not have to worry about passing arguments. Why pass arguments if you don't need to? After placing the calendar in the other form, use the code that you used in the edit form. Or go to the Visual Basic Editor and bring up your Calendar under the Object Combo Box then go to the Click Event in the Procedure Combo Box. The reason you can not do an OnClick Event from the Calendar property is because it does not allow an OnClick Event from the Properties Window - How Peculiar; however, you can get the OnClick Event in the VB Editor. The following one liner will do it: Me.Date(or name of your field).Value = Me.Calendar1(or the exact name of your Calendar9 control).Value

Again - Me.Date.Value = Me.Calendar1.value

Hope this works.

David






Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo to Search for Record w/Calendar Object Odeh Naber Access 10 May 14th, 2007 07:23 AM
Pull up or Create Record on Calendar Click Maverick10gk Pro VB Databases 10 April 26th, 2007 02:23 PM
Submitting a form after a calendar date selection programmher Javascript How-To 2 August 2nd, 2005 06:02 PM
how to retrieve the current date from the calendar johnsonlim026 ASP.NET 1.0 and 1.1 Basics 1 July 8th, 2005 01:19 PM
Calendar Control 9 .. separating date vars Chantale Access VBA 2 December 2nd, 2004 03:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.