A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Actual Date



 
 
Thread Tools Display Modes
  #1  
Old June 16th, 2008, 04:08 PM posted to microsoft.public.access.gettingstarted
Alimbilo
external usenet poster
 
Posts: 41
Default Actual Date

How can I have a form to show the actual date as soon as it open and have the
data empty ready for input?

I tried "On Current" but it doesn't let me move back to a previous date.

Thanks.
  #2  
Old June 16th, 2008, 05:38 PM posted to microsoft.public.access.gettingstarted
Klatuu
external usenet poster
 
Posts: 7,074
Default Actual Date

Well, there isn't enough information in your post to give you an exact
answer. It really depends on whether the control you want to show the date
in is a bound or unbound control. It also depends on whether you are opening
the form in edit or add mode.
A more detailed description would be useful.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

How can I have a form to show the actual date as soon as it open and have the
data empty ready for input?

I tried "On Current" but it doesn't let me move back to a previous date.

Thanks.

  #3  
Old June 16th, 2008, 05:53 PM posted to microsoft.public.access.gettingstarted
Alimbilo
external usenet poster
 
Posts: 41
Default Actual Date

Ok.
The Date is a bound control.
What I am trying to do is whenever I click on the Date I choose in the
calendar, I want all the fields value to be the records that I have put on
that day.

Right now, I have a popup calendar but It doesn't really do what I want. I
click on the date but nothing change in the fields.

Hope you understand me. Thanks

"Klatuu" wrote:

Well, there isn't enough information in your post to give you an exact
answer. It really depends on whether the control you want to show the date
in is a bound or unbound control. It also depends on whether you are opening
the form in edit or add mode.
A more detailed description would be useful.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

How can I have a form to show the actual date as soon as it open and have the
data empty ready for input?

I tried "On Current" but it doesn't let me move back to a previous date.

Thanks.

  #4  
Old June 16th, 2008, 05:59 PM posted to microsoft.public.access.gettingstarted
Klatuu
external usenet poster
 
Posts: 7,074
Default Actual Date

Are you saying you want to choose a date and have your form only show records
that have a date field that is equal to the date you choose?

If so, use the After Update event of the control where you choose the date
to set the form's Filter and Filteron properties.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

Ok.
The Date is a bound control.
What I am trying to do is whenever I click on the Date I choose in the
calendar, I want all the fields value to be the records that I have put on
that day.

Right now, I have a popup calendar but It doesn't really do what I want. I
click on the date but nothing change in the fields.

Hope you understand me. Thanks

"Klatuu" wrote:

Well, there isn't enough information in your post to give you an exact
answer. It really depends on whether the control you want to show the date
in is a bound or unbound control. It also depends on whether you are opening
the form in edit or add mode.
A more detailed description would be useful.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

How can I have a form to show the actual date as soon as it open and have the
data empty ready for input?

I tried "On Current" but it doesn't let me move back to a previous date.

Thanks.

  #5  
Old June 16th, 2008, 06:09 PM posted to microsoft.public.access.gettingstarted
Alimbilo
external usenet poster
 
Posts: 41
Default Actual Date

Yes, I am.
How do I set the Form Filter and Filterons properties?
And in the After Update event, what should I put in there.


"Klatuu" wrote:

Are you saying you want to choose a date and have your form only show records
that have a date field that is equal to the date you choose?

If so, use the After Update event of the control where you choose the date
to set the form's Filter and Filteron properties.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

Ok.
The Date is a bound control.
What I am trying to do is whenever I click on the Date I choose in the
calendar, I want all the fields value to be the records that I have put on
that day.

Right now, I have a popup calendar but It doesn't really do what I want. I
click on the date but nothing change in the fields.

Hope you understand me. Thanks

"Klatuu" wrote:

Well, there isn't enough information in your post to give you an exact
answer. It really depends on whether the control you want to show the date
in is a bound or unbound control. It also depends on whether you are opening
the form in edit or add mode.
A more detailed description would be useful.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

How can I have a form to show the actual date as soon as it open and have the
data empty ready for input?

I tried "On Current" but it doesn't let me move back to a previous date.

Thanks.

  #6  
Old June 16th, 2008, 06:23 PM posted to microsoft.public.access.gettingstarted
Klatuu
external usenet poster
 
Posts: 7,074
Default Actual Date

Me.Filter = "[NameOfDateField] = #" & Me.DateControl & "#"
Me.FilterOn = True

[NameOfDateField] would be the name of the field in the form's record source
you want to filter on and Me.DateControl would be the name of the control you
enter the date in. It would be in the After Update event of that control.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

Yes, I am.
How do I set the Form Filter and Filterons properties?
And in the After Update event, what should I put in there.


"Klatuu" wrote:

Are you saying you want to choose a date and have your form only show records
that have a date field that is equal to the date you choose?

If so, use the After Update event of the control where you choose the date
to set the form's Filter and Filteron properties.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

Ok.
The Date is a bound control.
What I am trying to do is whenever I click on the Date I choose in the
calendar, I want all the fields value to be the records that I have put on
that day.

Right now, I have a popup calendar but It doesn't really do what I want. I
click on the date but nothing change in the fields.

Hope you understand me. Thanks

"Klatuu" wrote:

Well, there isn't enough information in your post to give you an exact
answer. It really depends on whether the control you want to show the date
in is a bound or unbound control. It also depends on whether you are opening
the form in edit or add mode.
A more detailed description would be useful.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

How can I have a form to show the actual date as soon as it open and have the
data empty ready for input?

I tried "On Current" but it doesn't let me move back to a previous date.

Thanks.

  #7  
Old June 16th, 2008, 06:41 PM posted to microsoft.public.access.gettingstarted
Alimbilo
external usenet poster
 
Posts: 41
Default Actual Date

This is how the all concept is.
I have download the Calendar DB from an MVP website. and they have given
instruction hoe to configure it on your own website.

That Calendar has 2 part:
1. a module:
Option Compare Database
Option Explicit

'Calendar form variable:
Public gtxtCalTarget As TextBox 'Text box to return the date from the
calendar to.

Public Function CalendarFor(txt As TextBox, Optional strTitle As String)
'On Error GoTo Err_Handler
'Purpose: Open the calendar form, identifying the text box to return
the date to.
'Arguments: txt = the text box to return the date to.
' strTitle = the caption for the calendar form (passed in
OpenArgs).

Set gtxtCalTarget = txt
DoCmd.OpenForm "frmCalendar", windowmode:=acDialog, OpenArgs:=strTitle

Exit_Handler:
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, vbExclamation,
"CalendarFor()"
Resume Exit_Handler
End Function

Public Function LogError(lngErr As Long, strDescrip As String, strProc As
String, _
Optional bShowUser As Boolean = True, Optional varParam As Variant)
'Purpose: Minimal substitute for the real error logger function at:
' http://allenbrowne.com/ser-23a.html

If bShowUser Then
MsgBox "Error " & lngErr & ": " & strDescrip, vbExclamation, strProc
End If
End Function


And a Form which contains this code:

'Copyright: Allen Browne's Database And Training, 2007.
'Author: Allen Browne.
Option Compare Database
Option Explicit

Private Const conMod = "frmCalendar"

Private Sub cmdCancel_Click()
On Error GoTo Err_Handler
'Purpose: Close without transferring date back to calling text box.

DoCmd.Close acForm, Me.Name, acSaveNo

Exit_Handler:
Exit Sub

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".cmdCancel_Click")
Resume Exit_Handler
End Sub

Private Sub cmdMonthDown_Click()
Call SetDate("M", -1)
End Sub
Private Sub cmdMonthUp_Click()
Call SetDate("M", 1)
End Sub

Private Sub cmdOk_Click()
On Error Resume Next
'Purpose: Transfer the result back to the calling text box (if there
is one), and close.

If Me.cmdOk.Enabled Then
If gtxtCalTarget = Me.txtDate Then
'do nothing
Else
gtxtCalTarget = Me.txtDate
End If
End If
gtxtCalTarget.SetFocus
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

Private Sub cmdToday_Click()
'On Error GoTo Err_Handler
'Purpose: Set today.

Me.txtDate = Date
Call ShowCal

Exit_Handler:
Exit Sub

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".cmdToday_Click")
Resume Exit_Handler
End Sub

Private Sub cmdYearDown_Click()
Call SetDate("YYYY", -1)
End Sub
Private Sub cmdYearUp_Click()
Call SetDate("YYYY", 1)
End Sub

Private Sub Form_AfterUpdate()
Me.Filter = "[Date] = #" & Me.Calendar & "#"
Me.FilterOn = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'On Error GoTo Err_Handler
'Purpose:

With Me.txtDate
Select Case KeyCode
Case vbKeyLeft '1 day left or right.
.Value = .Value - 1
KeyCode = 0
Call ShowCal
Case vbKeyRight
.Value = .Value + 1
KeyCode = 0
Call ShowCal
Case vbKeyUp '1 week up or down.
.Value = .Value - 7
KeyCode = 0
Call ShowCal
Case vbKeyDown
.Value = .Value + 7
KeyCode = 0
Call ShowCal
Case vbKeyHome 'Home/End = first/last of this month.
.Value = .Value - Day(.Value) + 1
KeyCode = 0
Call ShowCal
Case vbKeyEnd
.Value = DateSerial(Year(.Value), Month(.Value) + 1, 0)
KeyCode = 0
Call ShowCal
Case vbKeyPageUp 'PgUp/PgDn = previous/next month.
.Value = DateAdd("m", -1, .Value)
KeyCode = 0
Call ShowCal
Case vbKeyPageDown
.Value = DateAdd("m", 1, .Value)
KeyCode = 0
Call ShowCal
Case vbKeyT, vbKeyT + 32 'T or t = today
.Value = Date
KeyCode = 0
Call ShowCal
End Select
End With

Exit_Handler:
Exit Sub

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".Form_KeyDown")
Resume Exit_Handler
End Sub

Private Sub Form_Open(Cancel As Integer)
'On Error GoTo Form_Open_Err
Dim bEnabled As Boolean

'Initialize to the existing date, or today if null.
If IsDate(gtxtCalTarget) Then
Me.txtDate = gtxtCalTarget.Value
Else
Me.txtDate = Date
End If

'Lock the Ok button if the text box is locked or disabled.
bEnabled = (gtxtCalTarget.Enabled) And (Not gtxtCalTarget.Locked)
With Me.cmdOk
If .Enabled bEnabled Then
.Enabled = bEnabled
End If
End With

'Set the title
If Len(Me.OpenArgs) 0& Then
Me.Caption = Me.OpenArgs
End If

'Set up the calendar for this month.
Call ShowCal

Form_Open_Exit:
Exit Sub

Form_Open_Err:
MsgBox Err.Description, vbCritical, "frmCalendar.Form_Open"
Resume Form_Open_Exit
End Sub

Private Function SetSelected(ctlName As String)
On Error GoTo Err_Handler

Me.txtDate = DateSerial(Year(txtDate), Month(txtDate),
CLng(Me(ctlName).Caption))
Call ShowHighligher(ctlName)

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".SetSelected")
Resume Exit_Handler
End Function

Private Function SelectDate(ctlName As String)
Call SetSelected(ctlName)
Call cmdOk_Click
End Function

Private Function SetDate(Subject As String, Optional intStep As Integer = 1)
On Error GoTo Err_Handler

Me.txtDate = DateAdd(Subject, intStep, Me.txtDate)
Call ShowCal

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".SetDate")
Resume Exit_Handler
End Function

Private Function ShowCal() As Boolean
On Error GoTo Err_Handler
'Purpose:
Dim dtStartDate As Date 'First of month
Dim iDays As Integer 'Days in month
Dim iOffset As Integer 'Offset to first label for month.
Dim i As Integer 'Loop controller.
Dim iDay As Integer 'Day under consideration.
Dim bShow As Boolean 'Flag: show label

dtStartDate = Me.txtDate - Day(Me.txtDate) + 1 'First of month
iDays = Day(DateAdd("m", 1, dtStartDate) - 1) 'Days in month.
iOffset = Weekday(dtStartDate, vbSunday) - 2 'Offset to first label
for month.

For i = 0 To 41
With Me("lblDay" & Format(i, "00"))
iDay = i - iOffset
bShow = ((iDay 0) And (iDay = iDays))
If .Visible bShow Then
.Visible = bShow
End If
If (bShow) And (.Caption iDay) Then
.Caption = iDay
End If
End With
Next

Call ShowHighligher("lblDay" & Format(Day(Me.txtDate) + iOffset, "00"))

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".ShowCal")
Resume Exit_Handler
End Function

Private Function ShowHighligher(ctlName As String)
On Error GoTo Err_Handler
Const lngcVOffset As Long = -83

With Me(ctlName)
Me.lblHighlight.Left = .Left
Me.lblHighlight.Top = .Top + lngcVOffset
End With

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".ShowHighligher")
Resume Exit_Handler
End Function

Private Sub lblHelp_Click()
MsgBox Me.lblHelp.ControlTipText, vbInformation, "Calendar help"
End Sub


Which one is the Control Name for the Calendar? That where I am confuse.
In my for the Calendar does Popup really good and I have the Date field
change whenever I pick a date. That part works fine but the Filter Part
doesn't.

I really appreciate your help. Really Do.



"Klatuu" wrote:

Me.Filter = "[NameOfDateField] = #" & Me.DateControl & "#"
Me.FilterOn = True

[NameOfDateField] would be the name of the field in the form's record source
you want to filter on and Me.DateControl would be the name of the control you
enter the date in. It would be in the After Update event of that control.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

Yes, I am.
How do I set the Form Filter and Filterons properties?
And in the After Update event, what should I put in there.


"Klatuu" wrote:

Are you saying you want to choose a date and have your form only show records
that have a date field that is equal to the date you choose?

If so, use the After Update event of the control where you choose the date
to set the form's Filter and Filteron properties.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

Ok.
The Date is a bound control.
What I am trying to do is whenever I click on the Date I choose in the
calendar, I want all the fields value to be the records that I have put on
that day.

Right now, I have a popup calendar but It doesn't really do what I want. I
click on the date but nothing change in the fields.

Hope you understand me. Thanks

"Klatuu" wrote:

Well, there isn't enough information in your post to give you an exact
answer. It really depends on whether the control you want to show the date
in is a bound or unbound control. It also depends on whether you are opening
the form in edit or add mode.
A more detailed description would be useful.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

How can I have a form to show the actual date as soon as it open and have the
data empty ready for input?

I tried "On Current" but it doesn't let me move back to a previous date.

Thanks.

  #8  
Old June 16th, 2008, 06:48 PM posted to microsoft.public.access.gettingstarted
Klatuu
external usenet poster
 
Posts: 7,074
Default Actual Date

The filtering code does not go in the calendar form. It goes in the control
on your form where you call the calander. It returns the value to your form,
then you use the After Update event of the control on your form.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

This is how the all concept is.
I have download the Calendar DB from an MVP website. and they have given
instruction hoe to configure it on your own website.

That Calendar has 2 part:
1. a module:
Option Compare Database
Option Explicit

'Calendar form variable:
Public gtxtCalTarget As TextBox 'Text box to return the date from the
calendar to.

Public Function CalendarFor(txt As TextBox, Optional strTitle As String)
'On Error GoTo Err_Handler
'Purpose: Open the calendar form, identifying the text box to return
the date to.
'Arguments: txt = the text box to return the date to.
' strTitle = the caption for the calendar form (passed in
OpenArgs).

Set gtxtCalTarget = txt
DoCmd.OpenForm "frmCalendar", windowmode:=acDialog, OpenArgs:=strTitle

Exit_Handler:
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, vbExclamation,
"CalendarFor()"
Resume Exit_Handler
End Function

Public Function LogError(lngErr As Long, strDescrip As String, strProc As
String, _
Optional bShowUser As Boolean = True, Optional varParam As Variant)
'Purpose: Minimal substitute for the real error logger function at:
' http://allenbrowne.com/ser-23a.html

If bShowUser Then
MsgBox "Error " & lngErr & ": " & strDescrip, vbExclamation, strProc
End If
End Function


And a Form which contains this code:

'Copyright: Allen Browne's Database And Training, 2007.
'Author: Allen Browne.
Option Compare Database
Option Explicit

Private Const conMod = "frmCalendar"

Private Sub cmdCancel_Click()
On Error GoTo Err_Handler
'Purpose: Close without transferring date back to calling text box.

DoCmd.Close acForm, Me.Name, acSaveNo

Exit_Handler:
Exit Sub

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".cmdCancel_Click")
Resume Exit_Handler
End Sub

Private Sub cmdMonthDown_Click()
Call SetDate("M", -1)
End Sub
Private Sub cmdMonthUp_Click()
Call SetDate("M", 1)
End Sub

Private Sub cmdOk_Click()
On Error Resume Next
'Purpose: Transfer the result back to the calling text box (if there
is one), and close.

If Me.cmdOk.Enabled Then
If gtxtCalTarget = Me.txtDate Then
'do nothing
Else
gtxtCalTarget = Me.txtDate
End If
End If
gtxtCalTarget.SetFocus
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

Private Sub cmdToday_Click()
'On Error GoTo Err_Handler
'Purpose: Set today.

Me.txtDate = Date
Call ShowCal

Exit_Handler:
Exit Sub

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".cmdToday_Click")
Resume Exit_Handler
End Sub

Private Sub cmdYearDown_Click()
Call SetDate("YYYY", -1)
End Sub
Private Sub cmdYearUp_Click()
Call SetDate("YYYY", 1)
End Sub

Private Sub Form_AfterUpdate()
Me.Filter = "[Date] = #" & Me.Calendar & "#"
Me.FilterOn = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'On Error GoTo Err_Handler
'Purpose:

With Me.txtDate
Select Case KeyCode
Case vbKeyLeft '1 day left or right.
.Value = .Value - 1
KeyCode = 0
Call ShowCal
Case vbKeyRight
.Value = .Value + 1
KeyCode = 0
Call ShowCal
Case vbKeyUp '1 week up or down.
.Value = .Value - 7
KeyCode = 0
Call ShowCal
Case vbKeyDown
.Value = .Value + 7
KeyCode = 0
Call ShowCal
Case vbKeyHome 'Home/End = first/last of this month.
.Value = .Value - Day(.Value) + 1
KeyCode = 0
Call ShowCal
Case vbKeyEnd
.Value = DateSerial(Year(.Value), Month(.Value) + 1, 0)
KeyCode = 0
Call ShowCal
Case vbKeyPageUp 'PgUp/PgDn = previous/next month.
.Value = DateAdd("m", -1, .Value)
KeyCode = 0
Call ShowCal
Case vbKeyPageDown
.Value = DateAdd("m", 1, .Value)
KeyCode = 0
Call ShowCal
Case vbKeyT, vbKeyT + 32 'T or t = today
.Value = Date
KeyCode = 0
Call ShowCal
End Select
End With

Exit_Handler:
Exit Sub

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".Form_KeyDown")
Resume Exit_Handler
End Sub

Private Sub Form_Open(Cancel As Integer)
'On Error GoTo Form_Open_Err
Dim bEnabled As Boolean

'Initialize to the existing date, or today if null.
If IsDate(gtxtCalTarget) Then
Me.txtDate = gtxtCalTarget.Value
Else
Me.txtDate = Date
End If

'Lock the Ok button if the text box is locked or disabled.
bEnabled = (gtxtCalTarget.Enabled) And (Not gtxtCalTarget.Locked)
With Me.cmdOk
If .Enabled bEnabled Then
.Enabled = bEnabled
End If
End With

'Set the title
If Len(Me.OpenArgs) 0& Then
Me.Caption = Me.OpenArgs
End If

'Set up the calendar for this month.
Call ShowCal

Form_Open_Exit:
Exit Sub

Form_Open_Err:
MsgBox Err.Description, vbCritical, "frmCalendar.Form_Open"
Resume Form_Open_Exit
End Sub

Private Function SetSelected(ctlName As String)
On Error GoTo Err_Handler

Me.txtDate = DateSerial(Year(txtDate), Month(txtDate),
CLng(Me(ctlName).Caption))
Call ShowHighligher(ctlName)

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".SetSelected")
Resume Exit_Handler
End Function

Private Function SelectDate(ctlName As String)
Call SetSelected(ctlName)
Call cmdOk_Click
End Function

Private Function SetDate(Subject As String, Optional intStep As Integer = 1)
On Error GoTo Err_Handler

Me.txtDate = DateAdd(Subject, intStep, Me.txtDate)
Call ShowCal

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".SetDate")
Resume Exit_Handler
End Function

Private Function ShowCal() As Boolean
On Error GoTo Err_Handler
'Purpose:
Dim dtStartDate As Date 'First of month
Dim iDays As Integer 'Days in month
Dim iOffset As Integer 'Offset to first label for month.
Dim i As Integer 'Loop controller.
Dim iDay As Integer 'Day under consideration.
Dim bShow As Boolean 'Flag: show label

dtStartDate = Me.txtDate - Day(Me.txtDate) + 1 'First of month
iDays = Day(DateAdd("m", 1, dtStartDate) - 1) 'Days in month.
iOffset = Weekday(dtStartDate, vbSunday) - 2 'Offset to first label
for month.

For i = 0 To 41
With Me("lblDay" & Format(i, "00"))
iDay = i - iOffset
bShow = ((iDay 0) And (iDay = iDays))
If .Visible bShow Then
.Visible = bShow
End If
If (bShow) And (.Caption iDay) Then
.Caption = iDay
End If
End With
Next

Call ShowHighligher("lblDay" & Format(Day(Me.txtDate) + iOffset, "00"))

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".ShowCal")
Resume Exit_Handler
End Function

Private Function ShowHighligher(ctlName As String)
On Error GoTo Err_Handler
Const lngcVOffset As Long = -83

With Me(ctlName)
Me.lblHighlight.Left = .Left
Me.lblHighlight.Top = .Top + lngcVOffset
End With

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".ShowHighligher")
Resume Exit_Handler
End Function

Private Sub lblHelp_Click()
MsgBox Me.lblHelp.ControlTipText, vbInformation, "Calendar help"
End Sub


  #9  
Old June 16th, 2008, 07:07 PM posted to microsoft.public.access.gettingstarted
Alimbilo
external usenet poster
 
Posts: 41
Default Actual Date

To call the Calendar on my form, I have added a Command Button that I named
"Calendarb".
And the date text box name on the form is "MyDate" which is bound to "Date"
field in a table.

So If I understand you answers, the code will be:
Me.Filter = "[Date] = #" & Me.Calendarb & "#"
Me.FilterOn = True

Right?

Thanks.




"Klatuu" wrote:

The filtering code does not go in the calendar form. It goes in the control
on your form where you call the calander. It returns the value to your form,
then you use the After Update event of the control on your form.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

This is how the all concept is.
I have download the Calendar DB from an MVP website. and they have given
instruction hoe to configure it on your own website.

That Calendar has 2 part:
1. a module:
Option Compare Database
Option Explicit

'Calendar form variable:
Public gtxtCalTarget As TextBox 'Text box to return the date from the
calendar to.

Public Function CalendarFor(txt As TextBox, Optional strTitle As String)
'On Error GoTo Err_Handler
'Purpose: Open the calendar form, identifying the text box to return
the date to.
'Arguments: txt = the text box to return the date to.
' strTitle = the caption for the calendar form (passed in
OpenArgs).

Set gtxtCalTarget = txt
DoCmd.OpenForm "frmCalendar", windowmode:=acDialog, OpenArgs:=strTitle

Exit_Handler:
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, vbExclamation,
"CalendarFor()"
Resume Exit_Handler
End Function

Public Function LogError(lngErr As Long, strDescrip As String, strProc As
String, _
Optional bShowUser As Boolean = True, Optional varParam As Variant)
'Purpose: Minimal substitute for the real error logger function at:
' http://allenbrowne.com/ser-23a.html

If bShowUser Then
MsgBox "Error " & lngErr & ": " & strDescrip, vbExclamation, strProc
End If
End Function


And a Form which contains this code:

'Copyright: Allen Browne's Database And Training, 2007.
'Author: Allen Browne.
Option Compare Database
Option Explicit

Private Const conMod = "frmCalendar"

Private Sub cmdCancel_Click()
On Error GoTo Err_Handler
'Purpose: Close without transferring date back to calling text box.

DoCmd.Close acForm, Me.Name, acSaveNo

Exit_Handler:
Exit Sub

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".cmdCancel_Click")
Resume Exit_Handler
End Sub

Private Sub cmdMonthDown_Click()
Call SetDate("M", -1)
End Sub
Private Sub cmdMonthUp_Click()
Call SetDate("M", 1)
End Sub

Private Sub cmdOk_Click()
On Error Resume Next
'Purpose: Transfer the result back to the calling text box (if there
is one), and close.

If Me.cmdOk.Enabled Then
If gtxtCalTarget = Me.txtDate Then
'do nothing
Else
gtxtCalTarget = Me.txtDate
End If
End If
gtxtCalTarget.SetFocus
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

Private Sub cmdToday_Click()
'On Error GoTo Err_Handler
'Purpose: Set today.

Me.txtDate = Date
Call ShowCal

Exit_Handler:
Exit Sub

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".cmdToday_Click")
Resume Exit_Handler
End Sub

Private Sub cmdYearDown_Click()
Call SetDate("YYYY", -1)
End Sub
Private Sub cmdYearUp_Click()
Call SetDate("YYYY", 1)
End Sub

Private Sub Form_AfterUpdate()
Me.Filter = "[Date] = #" & Me.Calendar & "#"
Me.FilterOn = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'On Error GoTo Err_Handler
'Purpose:

With Me.txtDate
Select Case KeyCode
Case vbKeyLeft '1 day left or right.
.Value = .Value - 1
KeyCode = 0
Call ShowCal
Case vbKeyRight
.Value = .Value + 1
KeyCode = 0
Call ShowCal
Case vbKeyUp '1 week up or down.
.Value = .Value - 7
KeyCode = 0
Call ShowCal
Case vbKeyDown
.Value = .Value + 7
KeyCode = 0
Call ShowCal
Case vbKeyHome 'Home/End = first/last of this month.
.Value = .Value - Day(.Value) + 1
KeyCode = 0
Call ShowCal
Case vbKeyEnd
.Value = DateSerial(Year(.Value), Month(.Value) + 1, 0)
KeyCode = 0
Call ShowCal
Case vbKeyPageUp 'PgUp/PgDn = previous/next month.
.Value = DateAdd("m", -1, .Value)
KeyCode = 0
Call ShowCal
Case vbKeyPageDown
.Value = DateAdd("m", 1, .Value)
KeyCode = 0
Call ShowCal
Case vbKeyT, vbKeyT + 32 'T or t = today
.Value = Date
KeyCode = 0
Call ShowCal
End Select
End With

Exit_Handler:
Exit Sub

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".Form_KeyDown")
Resume Exit_Handler
End Sub

Private Sub Form_Open(Cancel As Integer)
'On Error GoTo Form_Open_Err
Dim bEnabled As Boolean

'Initialize to the existing date, or today if null.
If IsDate(gtxtCalTarget) Then
Me.txtDate = gtxtCalTarget.Value
Else
Me.txtDate = Date
End If

'Lock the Ok button if the text box is locked or disabled.
bEnabled = (gtxtCalTarget.Enabled) And (Not gtxtCalTarget.Locked)
With Me.cmdOk
If .Enabled bEnabled Then
.Enabled = bEnabled
End If
End With

'Set the title
If Len(Me.OpenArgs) 0& Then
Me.Caption = Me.OpenArgs
End If

'Set up the calendar for this month.
Call ShowCal

Form_Open_Exit:
Exit Sub

Form_Open_Err:
MsgBox Err.Description, vbCritical, "frmCalendar.Form_Open"
Resume Form_Open_Exit
End Sub

Private Function SetSelected(ctlName As String)
On Error GoTo Err_Handler

Me.txtDate = DateSerial(Year(txtDate), Month(txtDate),
CLng(Me(ctlName).Caption))
Call ShowHighligher(ctlName)

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".SetSelected")
Resume Exit_Handler
End Function

Private Function SelectDate(ctlName As String)
Call SetSelected(ctlName)
Call cmdOk_Click
End Function

Private Function SetDate(Subject As String, Optional intStep As Integer = 1)
On Error GoTo Err_Handler

Me.txtDate = DateAdd(Subject, intStep, Me.txtDate)
Call ShowCal

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".SetDate")
Resume Exit_Handler
End Function

Private Function ShowCal() As Boolean
On Error GoTo Err_Handler
'Purpose:
Dim dtStartDate As Date 'First of month
Dim iDays As Integer 'Days in month
Dim iOffset As Integer 'Offset to first label for month.
Dim i As Integer 'Loop controller.
Dim iDay As Integer 'Day under consideration.
Dim bShow As Boolean 'Flag: show label

dtStartDate = Me.txtDate - Day(Me.txtDate) + 1 'First of month
iDays = Day(DateAdd("m", 1, dtStartDate) - 1) 'Days in month.
iOffset = Weekday(dtStartDate, vbSunday) - 2 'Offset to first label
for month.

For i = 0 To 41
With Me("lblDay" & Format(i, "00"))
iDay = i - iOffset
bShow = ((iDay 0) And (iDay = iDays))
If .Visible bShow Then
.Visible = bShow
End If
If (bShow) And (.Caption iDay) Then
.Caption = iDay
End If
End With
Next

Call ShowHighligher("lblDay" & Format(Day(Me.txtDate) + iOffset, "00"))

Exit_Handler:
Exit Function

Err_Handler:
Call LogError(Err.Number, Err.Description, conMod & ".ShowCal")
Resume Exit_Handler
End Function

Private Function ShowHighligher(ctlName As String)
On Error GoTo Err_Handler
Const lngcVOffset As Long = -83

With Me(ctlName)
Me.lblHighlight.Left = .Left
Me.lblHighlight.Top = .Top + lngcVOffset
End With

Exit_Handler:
Exit Function

Err_Handler:

  #10  
Old June 16th, 2008, 07:08 PM posted to microsoft.public.access.gettingstarted
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Actual Date

picky

Not all users live in the US. Many may have their Short Date format set to
dd/mm/yyyy, so setting the filter that way can be dangerous.

Far safer is

Me.Filter = "[NameOfDateField] = " & Format(Me.DateControl,
"\#yyyy\-mm\-dd\#")

/picky


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Klatuu" wrote in message
...
Me.Filter = "[NameOfDateField] = #" & Me.DateControl & "#"
Me.FilterOn = True

[NameOfDateField] would be the name of the field in the form's record
source
you want to filter on and Me.DateControl would be the name of the control
you
enter the date in. It would be in the After Update event of that control.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

Yes, I am.
How do I set the Form Filter and Filterons properties?
And in the After Update event, what should I put in there.


"Klatuu" wrote:

Are you saying you want to choose a date and have your form only show
records
that have a date field that is equal to the date you choose?

If so, use the After Update event of the control where you choose the
date
to set the form's Filter and Filteron properties.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

Ok.
The Date is a bound control.
What I am trying to do is whenever I click on the Date I choose in
the
calendar, I want all the fields value to be the records that I have
put on
that day.

Right now, I have a popup calendar but It doesn't really do what I
want. I
click on the date but nothing change in the fields.

Hope you understand me. Thanks

"Klatuu" wrote:

Well, there isn't enough information in your post to give you an
exact
answer. It really depends on whether the control you want to show
the date
in is a bound or unbound control. It also depends on whether you
are opening
the form in edit or add mode.
A more detailed description would be useful.
--
Dave Hargis, Microsoft Access MVP


"Alimbilo" wrote:

How can I have a form to show the actual date as soon as it open
and have the
data empty ready for input?

I tried "On Current" but it doesn't let me move back to a
previous date.

Thanks.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:10 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.