INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

calendar control and after update event

calendar control and after update event

(OP)
HI guys
ver 2010
I have a form with a date field with the calendar control.
The after update event simply uses msg to show the value in the date field.
If I select a date from the calendar the msg shows nothing , although the field on the form is correct

If I enter the date everything works.

Can anyone explain ??

Thanks in advance

RE: calendar control and after update event

You may need to use a different event. I recall setting the value with VBA code also doesn't trigger the After Update event.

Duane
Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016

RE: calendar control and after update event

(OP)
Just had a thought.
When you enter the date of course you see it and hit enter.
With the calendar control you see it on the form and its only when you go to another control is then updated.
It might have to be the next control that executes the code.

RE: calendar control and after update event

The OnChange might work but it would fire on every keystroke from a user which would be annoying if you add a msgbox.

CODE --> vba

Private Sub StartDate_Change()
    If IsDate(Me.StartDate.Text) And Len(Me.StartDate.Text) > 7 Then 'maybe some other checks
        MsgBox "On Change"
    End If
End Sub

Private Sub StartDate_LostFocus()
    MsgBox "Lost Focus"
End Sub 

What's the purpose for the code?

Duane
Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016

RE: calendar control and after update event

(OP)
The code was to check the date with previous data.
The problem with the date calendar control is that if you select a date it is moved into the form but you still have to hit return.
I will put code elsewhere.

Thanks

RE: calendar control and after update event

Actually, unlike many previous ActiveX DatePickers and Form-based calendars, Access does consider the Control to be physically populated when done using the native DatePicker, meaning that all of the Control's associated events, such as the BeforeUpdate event, AfterUpdate event, etc, will fire.

The problem is that a Control's AfterUpdate event doesn't fire until you leave the Control.

One approach would be:

Force the user to use the DatePicker

CODE

Private Sub DateField_KeyDown(KeyCode As Integer, Shift As Integer)
 If KeyCode <> vbKeyTab And KeyCode <> vbKeyReturn Then
  KeyCode = 0
 End If
End Sub 


Move to another Control

CODE

Private Sub DateField_Change()
  AnotherControl.SetFocus
End Sub 

Execute your code in the Control's AfterUpdate event

CODE

Private Sub DateField_AfterUpdate()
 ' Place the desired code here
End Sub 

You need to replace DateField and AnotherControl with names of your actual Controls. And since the user can no longer enter the date, freehand, as it were, using the OnChange event won't fire repeatedly, showing the Messagebox over and over again.

Linq ;0)>

Hope this helps!

There's always more than one way to skin a cat!

All posts/responses based on Access 2003/2007

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close