calendar

A

Art Vandaley

Hi.

I have a code for a form like below:
----------------------------------------
Private Sub Calendar8_Click()

Text1.Value = Text159.Value
Text2.SetFocus

End sub
----------------------------------------

Control source of Text159 is something like "
=Format([calendar8]-Weekday([calendar8];2)+1;"dd/mm";2) "
Control source of Text1 is a field of related table.

Everytime I click the calendar Text1 shows the date of prior selection. For
example:

I click on "13rd April 2006" Text1 shows prior selection,
I click on "14th April 2006" Text1 shows "13rd April 2006"

Is there a solution to provide text1 to show most current selection on the
form.

Thanks a lot for your help. Regards.
 
N

Nikos Yannacopoulos

Art,

It's a timing issue. I suppose Text159 is updated after the click code
has run. I don't see though why you need Text159; if you don't need it
for any other purpose, then delete it altogether and make your code:

Private Sub Calendar8_Click()
Me.Text1 = Format([calendar8]-Weekday([calendar8];2)+1;"dd/mm";2)
Me.Text2.SetFocus
End sub

Which overcomes the timing issue. If you still need Text129, then remove
the expression form its Control Source property, and change your code to:

Private Sub Calendar8_Click()
Me.Text129 = Format([calendar8]-Weekday([calendar8];2)+1;"dd/mm";2)
Me.Text1 = Me.Text129
Me.Text2.SetFocus
End sub

HTH,
Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top