Solved

CALENDAR CONTROL!! WHERE AM I GOING WRONG!?

Posted on 2004-04-19
9
391 Views
Last Modified: 2008-03-17
I have the following code for the calendar in a module. Then in the text box on my frmMember i put the following in the OnEnter: box of the date field. =OpenCalendar("frmMember","ExpiryDate",0.3,0.399)

It works on this form but when i do the same thing on date fields on other forms the calendar pops up, but when i click the date it doesnt do anything. THe calendar stays visible andthe date does not update the fields. ANY IDEAS THANKS!!!



Option Compare Database

Dim ctrl As Control
Dim frm As Form
Const centimeter = 567

 Function OpenCalendar(strForm As String, strCtrl As String, intLeft, intTop)
    Set frm = Forms(strForm)
    Set ctrl = frm(strCtrl)
        frm("Calendar5").Visible = True
        frm("Calendar5").Left = intLeft * centimeter
        frm("Calendar5").Top = intTop * centimeter
        frm("Calendar5").Value = Date
End Function

Function CloseCalendar()
    frm(ctrl.Name).SetFocus
    frm("Calendar5").Visible = False
End Function

Sub SetDate()
    frm(ctrl.Name).Value = frm("Calendar5").Value
    frm(ctrl.Name).SetFocus
    frm("Calendar5").Visible = False
End Sub
0
Comment
Question by:jam90blue
  • 5
  • 3
9 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 10863883
Change this

=OpenCalendar("frmMember","ExpiryDate",0.3,0.399)
--------------------^^^^^^^  name of the form you are using
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 10863891
and also
=OpenCalendar("frmMember","ExpiryDate",0.3,0.399)
------------------------------------^^^^^^^ make sure that the field name is correct too.
0
 
LVL 11

Expert Comment

by:phileoca
ID: 10863892
try this beauty:

'Save the Module as BasCalendar
Option Compare Database   'Use database order for string comparisons
Option Explicit

' From Access 97 Developer's Handbook
' by Litwin, Getz, and Gilbert (Sybex)
' Copyright 1997.  All rights reserved.

Const adhcCalendarForm = "frmCalendar"

Function adhDoCalendar(Optional varPassedDate As Variant) As Variant
    '
    ' This is the public entry point.
    ' If the passed in date is missing (as it will
    ' be if someone just opens the Calendar form
    ' raw), start on the current day.
    ' Otherwise, start with the date that is passed in.
   
    ' From Access 97 Developer's Handbook
    ' by Litwin, Getz, and Gilbert (Sybex)
    ' Copyright 1997.  All rights reserved.
    '
    Dim varStartDate As Variant

    ' If they passed a value at all, attempt to
    ' use it as the start date.
    varStartDate = IIf(IsMissing(varPassedDate), _
     Date, varPassedDate)
    ' OK, so they passed a value that wasn't a date.
    ' Just use today's date in that case, too.
    If Not IsDate(varStartDate) Then varStartDate = Date
    DoCmd.OpenForm FormName:=adhcCalendarForm, _
     WindowMode:=acDialog, OpenArgs:=varStartDate

    ' You won't get here until the form is
    ' closed or hidden.
    '
    ' If the form is still loaded, then get the
    ' final chosen date from the form.  If it isn't,
    ' return Null.
    If isOpen(adhcCalendarForm) Then
        adhDoCalendar = Forms(adhcCalendarForm).Value
        DoCmd.close acForm, adhcCalendarForm
    Else
        adhDoCalendar = Null
    End If
End Function

Private Function isOpen(strName As String, _
 Optional intObjectType As Integer = acForm)
    ' Returns True if strName is open, False otherwise.
    ' Assume the caller wants to know about a form.
    isOpen = (SysCmd(acSysCmdGetObjectState, _
     intObjectType, strName) <> 0)
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'On the date field on the form that you want use this, call the function like this (example)

Private Sub StartDate_DblClick(Cancel As Integer)

    StartDate = adhDoCalendar(StartDate)

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
<>< kT
0
 

Author Comment

by:jam90blue
ID: 10864197
Hi capricorn,

i have changed that already, i must have putit in correctly as otherwise the calendar would not pop up at all.

ANyotherideas?
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 119

Expert Comment

by:Rey Obrero
ID: 10864214
What is the name of the form and field?
Post the code you place on the
On Enter  ?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 10864220
Is the name of the calendar on the new form Calendar5?
0
 

Author Comment

by:jam90blue
ID: 10867571
=OpenCalendar("frmCustomers2","DateOfBirth",0.199,0.199)

Like i said the form opens , but does not close when i click on it???
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 10868042
Copy and paste this codes on frmCustomers2 VBA window


Private Sub Calendar5_Click()
Call SetDate

End Sub

Check that the name of the calendar on frmCustomers2 is Calendar5
0
 

Author Comment

by:jam90blue
ID: 10869093
THANKS THAT WORKS!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now