Calendar control part 2

S

Sandy

I have a form "New Jobs" with a subform "NewJobsSubform", the container for
the subform is named "NJSubform".

On the form I have 10 controls in total the final two being
"txtDateOrdered" - bound to "DateOrdered", and "txtDateRequired" - bound to
"DateRequired" in a query. After the date is entered in "txtDateRequired"
pressing the tab key moves the focus to textbox "RepairWhat" in my subform.
All good and well.

I thought to simplify data entry I would introduce a pop-up calendar for
each of my date fields - here is my code (with a great deal of help from the
web!).

Private Sub txtDateOrdered_Enter()

Calendar3.Visible = True
Calendar3.SetFocus

If Not IsNull(txtDateOrdered) Then
Calendar3.Value = txtDateOrdered.Value
Else
Calendar3.Value = Date
End If

End Sub

Private Sub Calendar3_Click()

txtDateOrdered.Value = Calendar3.Value
txtDateRequired.SetFocus
Calendar3.Visible = False
Calendar4.Visible = True

End Sub

Private Sub Calendar4_Click()
txtDateRequired.Value = Calendar4.Value
Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus
'Calendar4.Visible = False

End Sub

The first two Subs - "Private Sub txtDateOrdered_Enter()" and "Private Sub
Calendar3_Click()" - works fine the calendar appears when the
"txtdateOrdered" is entered and a selection can be made. The focus then
shifts to "txtDateRequired" and the second calendar "calendar4" appears, (I
know that from checking in design view).

When I now select a date from the calendar it is inserted but I get an error
message saying :-
"Run-time error '2165':
You can't hide a control that has the focus"

I thought the line "Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus"
already had reset the focus?!?

Any suggestions?

Sandy
 
H

Hunter57

Hi Sandy

I hope this helps. To make sure your control has focus, you can use
Conditional Formating to make it change color when it has the focus.

You may already know how to do this but just in case I am giving the
instructions to set it.

Open your form or subform in design view. Select the text boxes and other
controls you want to check. Next click on "Format" on the Menu Bar. Then
select "Conditional Formatting". Under "Condition 1" select "Field has
focus".

At this point I usually select yellow as a background color so I can see
when it has the focus. After selecting your options, click OK.

Now when you click on your buttons you should be able to see whether a text
box is actually receiving the focus and when the focus changes to another
control.

Happy New Year,

Patrick Wood
 
S

Sandy

Hi Patrick,

Minor problem - the subform I am using is datasheet and the textboxes can't
be formatted (at least I don't think they can) however, using your
suggestion I placed my 3rd last textbox on my main form AFTER the two date
fields in tab order, adjusted the code and the whole thing worked perfectly.

So obviously the code line - "Forms![New
Jobs]!NJSubform.Form!RepairWhat.SetFocus" was not moving the focus at all.

I would prefer to have my original tab order but I am at a loss as to how to
make that work so I suppose I will just have to make do - unless you (or
anyone else) can suggest an alternative line of code to take the focus onto
my subform control.

Thank you and Happy New Year too.

Sandy


Hunter57 said:
Hi Sandy

I hope this helps. To make sure your control has focus, you can use
Conditional Formating to make it change color when it has the focus.

You may already know how to do this but just in case I am giving the
instructions to set it.

Open your form or subform in design view. Select the text boxes and other
controls you want to check. Next click on "Format" on the Menu Bar. Then
select "Conditional Formatting". Under "Condition 1" select "Field has
focus".

At this point I usually select yellow as a background color so I can see
when it has the focus. After selecting your options, click OK.

Now when you click on your buttons you should be able to see whether a
text
box is actually receiving the focus and when the focus changes to another
control.

Happy New Year,

Patrick Wood



Sandy said:
I have a form "New Jobs" with a subform "NewJobsSubform", the container
for
the subform is named "NJSubform".

On the form I have 10 controls in total the final two being
"txtDateOrdered" - bound to "DateOrdered", and "txtDateRequired" - bound
to
"DateRequired" in a query. After the date is entered in "txtDateRequired"
pressing the tab key moves the focus to textbox "RepairWhat" in my
subform.
All good and well.

I thought to simplify data entry I would introduce a pop-up calendar for
each of my date fields - here is my code (with a great deal of help from
the
web!).

Private Sub txtDateOrdered_Enter()

Calendar3.Visible = True
Calendar3.SetFocus

If Not IsNull(txtDateOrdered) Then
Calendar3.Value = txtDateOrdered.Value
Else
Calendar3.Value = Date
End If

End Sub

Private Sub Calendar3_Click()

txtDateOrdered.Value = Calendar3.Value
txtDateRequired.SetFocus
Calendar3.Visible = False
Calendar4.Visible = True

End Sub

Private Sub Calendar4_Click()
txtDateRequired.Value = Calendar4.Value
Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus
'Calendar4.Visible = False

End Sub

The first two Subs - "Private Sub txtDateOrdered_Enter()" and "Private
Sub
Calendar3_Click()" - works fine the calendar appears when the
"txtdateOrdered" is entered and a selection can be made. The focus then
shifts to "txtDateRequired" and the second calendar "calendar4" appears,
(I
know that from checking in design view).

When I now select a date from the calendar it is inserted but I get an
error
message saying :-
"Run-time error '2165':
You can't hide a control that has the focus"

I thought the line "Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus"
already had reset the focus?!?

Any suggestions?

Sandy
 
H

Hunter57

Hi Sandy,

I know how you feel. I can write code to loop through recordsets, build SQL
strings, change the properties of all controls in every form or report in a
database, but I cannot get my subform syntax right. It is so much easier to
use List Boxes so that is what I do whenever possible. List Boxes also use
less memory.

Even in datasheet view the conditional formatting should work.

If you can't get the help you need here, then you can try posting on this
site:

http://tech.groups.yahoo.com/group/MS_Access_Professionals/

A number of outstanding experts and Access MVP's are available to help you
there.

Best Regards,
Pat Wood


Sandy said:
Hi Patrick,

Minor problem - the subform I am using is datasheet and the textboxes can't
be formatted (at least I don't think they can) however, using your
suggestion I placed my 3rd last textbox on my main form AFTER the two date
fields in tab order, adjusted the code and the whole thing worked perfectly.

So obviously the code line - "Forms![New
Jobs]!NJSubform.Form!RepairWhat.SetFocus" was not moving the focus at all.

I would prefer to have my original tab order but I am at a loss as to how to
make that work so I suppose I will just have to make do - unless you (or
anyone else) can suggest an alternative line of code to take the focus onto
my subform control.

Thank you and Happy New Year too.

Sandy


Hunter57 said:
Hi Sandy

I hope this helps. To make sure your control has focus, you can use
Conditional Formating to make it change color when it has the focus.

You may already know how to do this but just in case I am giving the
instructions to set it.

Open your form or subform in design view. Select the text boxes and other
controls you want to check. Next click on "Format" on the Menu Bar. Then
select "Conditional Formatting". Under "Condition 1" select "Field has
focus".

At this point I usually select yellow as a background color so I can see
when it has the focus. After selecting your options, click OK.

Now when you click on your buttons you should be able to see whether a
text
box is actually receiving the focus and when the focus changes to another
control.

Happy New Year,

Patrick Wood



Sandy said:
I have a form "New Jobs" with a subform "NewJobsSubform", the container
for
the subform is named "NJSubform".

On the form I have 10 controls in total the final two being
"txtDateOrdered" - bound to "DateOrdered", and "txtDateRequired" - bound
to
"DateRequired" in a query. After the date is entered in "txtDateRequired"
pressing the tab key moves the focus to textbox "RepairWhat" in my
subform.
All good and well.

I thought to simplify data entry I would introduce a pop-up calendar for
each of my date fields - here is my code (with a great deal of help from
the
web!).

Private Sub txtDateOrdered_Enter()

Calendar3.Visible = True
Calendar3.SetFocus

If Not IsNull(txtDateOrdered) Then
Calendar3.Value = txtDateOrdered.Value
Else
Calendar3.Value = Date
End If

End Sub

Private Sub Calendar3_Click()

txtDateOrdered.Value = Calendar3.Value
txtDateRequired.SetFocus
Calendar3.Visible = False
Calendar4.Visible = True

End Sub

Private Sub Calendar4_Click()
txtDateRequired.Value = Calendar4.Value
Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus
'Calendar4.Visible = False

End Sub

The first two Subs - "Private Sub txtDateOrdered_Enter()" and "Private
Sub
Calendar3_Click()" - works fine the calendar appears when the
"txtdateOrdered" is entered and a selection can be made. The focus then
shifts to "txtDateRequired" and the second calendar "calendar4" appears,
(I
know that from checking in design view).

When I now select a date from the calendar it is inserted but I get an
error
message saying :-
"Run-time error '2165':
You can't hide a control that has the focus"

I thought the line "Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus"
already had reset the focus?!?

Any suggestions?

Sandy
 
S

Sandy

Hi Patrick

The conditional formatting does work in datasheet - I was stupidly trying to
set it in design view - oops.

I'll bear the other newsgroup in mind.

Thanks again for your assistance.

Sandy

Hunter57 said:
Hi Sandy,

I know how you feel. I can write code to loop through recordsets, build
SQL
strings, change the properties of all controls in every form or report in
a
database, but I cannot get my subform syntax right. It is so much easier
to
use List Boxes so that is what I do whenever possible. List Boxes also use
less memory.

Even in datasheet view the conditional formatting should work.

If you can't get the help you need here, then you can try posting on this
site:

http://tech.groups.yahoo.com/group/MS_Access_Professionals/

A number of outstanding experts and Access MVP's are available to help you
there.

Best Regards,
Pat Wood


Sandy said:
Hi Patrick,

Minor problem - the subform I am using is datasheet and the textboxes
can't
be formatted (at least I don't think they can) however, using your
suggestion I placed my 3rd last textbox on my main form AFTER the two
date
fields in tab order, adjusted the code and the whole thing worked
perfectly.

So obviously the code line - "Forms![New
Jobs]!NJSubform.Form!RepairWhat.SetFocus" was not moving the focus at
all.

I would prefer to have my original tab order but I am at a loss as to how
to
make that work so I suppose I will just have to make do - unless you (or
anyone else) can suggest an alternative line of code to take the focus
onto
my subform control.

Thank you and Happy New Year too.

Sandy


Hunter57 said:
Hi Sandy

I hope this helps. To make sure your control has focus, you can use
Conditional Formating to make it change color when it has the focus.

You may already know how to do this but just in case I am giving the
instructions to set it.

Open your form or subform in design view. Select the text boxes and
other
controls you want to check. Next click on "Format" on the Menu Bar.
Then
select "Conditional Formatting". Under "Condition 1" select "Field has
focus".

At this point I usually select yellow as a background color so I can
see
when it has the focus. After selecting your options, click OK.

Now when you click on your buttons you should be able to see whether a
text
box is actually receiving the focus and when the focus changes to
another
control.

Happy New Year,

Patrick Wood



:

I have a form "New Jobs" with a subform "NewJobsSubform", the
container
for
the subform is named "NJSubform".

On the form I have 10 controls in total the final two being
"txtDateOrdered" - bound to "DateOrdered", and "txtDateRequired" -
bound
to
"DateRequired" in a query. After the date is entered in
"txtDateRequired"
pressing the tab key moves the focus to textbox "RepairWhat" in my
subform.
All good and well.

I thought to simplify data entry I would introduce a pop-up calendar
for
each of my date fields - here is my code (with a great deal of help
from
the
web!).

Private Sub txtDateOrdered_Enter()

Calendar3.Visible = True
Calendar3.SetFocus

If Not IsNull(txtDateOrdered) Then
Calendar3.Value = txtDateOrdered.Value
Else
Calendar3.Value = Date
End If

End Sub

Private Sub Calendar3_Click()

txtDateOrdered.Value = Calendar3.Value
txtDateRequired.SetFocus
Calendar3.Visible = False
Calendar4.Visible = True

End Sub

Private Sub Calendar4_Click()
txtDateRequired.Value = Calendar4.Value
Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus
'Calendar4.Visible = False

End Sub

The first two Subs - "Private Sub txtDateOrdered_Enter()" and
"Private
Sub
Calendar3_Click()" - works fine the calendar appears when the
"txtdateOrdered" is entered and a selection can be made. The focus
then
shifts to "txtDateRequired" and the second calendar "calendar4"
appears,
(I
know that from checking in design view).

When I now select a date from the calendar it is inserted but I get an
error
message saying :-
"Run-time error '2165':
You can't hide a control that has the focus"

I thought the line "Forms![New
Jobs]!NJSubform.Form!RepairWhat.SetFocus"
already had reset the focus?!?

Any suggestions?

Sandy
 
T

Tony Toews [MVP]

Sandy said:
I thought to simplify data entry I would introduce a pop-up calendar for
each of my date fields -

See the Calendar Tips page at my website
http://www.granite.ab.ca/access/calendars.htm

There could, likely will, be lots of version problems when you go to
distribute the MSCal.OCX..

One alternative is MonthCalendar is a completely API generated Month
Calendar derived directly from the Common Control DLL. There are
links to several downloadable calendar forms at my website. As these
are forms you can also do anything with them you want.

You can also use the calendar form which comes in the Access <insert
your version here> Developers Handbook by Litwin/Getz/Gilbert,
publisher Sybex www.developershandbook.com. These books are well
worth spending money. Every time I open one I save the price of the
book.

Duane Hookum has an awesome and simple calendar in a report. See the
Calendar Reports sample section at
http://www.access.hookom.net/Samples.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
H

Hunter57

Hi Sandy,

Tony does have a great site. It is well worth checking out.

If you need a calendar I have an easy to use Form Calendar that I can email
to you. If you are interested just email me at pwood 57 at gm ail dot com.
I am sure you can figure out the email address. I get too much spam already.

Best Regards,
Patrick Wood

Sandy said:
Hi Patrick

The conditional formatting does work in datasheet - I was stupidly trying to
set it in design view - oops.

I'll bear the other newsgroup in mind.

Thanks again for your assistance.

Sandy

Hunter57 said:
Hi Sandy,

I know how you feel. I can write code to loop through recordsets, build
SQL
strings, change the properties of all controls in every form or report in
a
database, but I cannot get my subform syntax right. It is so much easier
to
use List Boxes so that is what I do whenever possible. List Boxes also use
less memory.

Even in datasheet view the conditional formatting should work.

If you can't get the help you need here, then you can try posting on this
site:

http://tech.groups.yahoo.com/group/MS_Access_Professionals/

A number of outstanding experts and Access MVP's are available to help you
there.

Best Regards,
Pat Wood


Sandy said:
Hi Patrick,

Minor problem - the subform I am using is datasheet and the textboxes
can't
be formatted (at least I don't think they can) however, using your
suggestion I placed my 3rd last textbox on my main form AFTER the two
date
fields in tab order, adjusted the code and the whole thing worked
perfectly.

So obviously the code line - "Forms![New
Jobs]!NJSubform.Form!RepairWhat.SetFocus" was not moving the focus at
all.

I would prefer to have my original tab order but I am at a loss as to how
to
make that work so I suppose I will just have to make do - unless you (or
anyone else) can suggest an alternative line of code to take the focus
onto
my subform control.

Thank you and Happy New Year too.

Sandy


Hi Sandy

I hope this helps. To make sure your control has focus, you can use
Conditional Formating to make it change color when it has the focus.

You may already know how to do this but just in case I am giving the
instructions to set it.

Open your form or subform in design view. Select the text boxes and
other
controls you want to check. Next click on "Format" on the Menu Bar.
Then
select "Conditional Formatting". Under "Condition 1" select "Field has
focus".

At this point I usually select yellow as a background color so I can
see
when it has the focus. After selecting your options, click OK.

Now when you click on your buttons you should be able to see whether a
text
box is actually receiving the focus and when the focus changes to
another
control.

Happy New Year,

Patrick Wood



:

I have a form "New Jobs" with a subform "NewJobsSubform", the
container
for
the subform is named "NJSubform".

On the form I have 10 controls in total the final two being
"txtDateOrdered" - bound to "DateOrdered", and "txtDateRequired" -
bound
to
"DateRequired" in a query. After the date is entered in
"txtDateRequired"
pressing the tab key moves the focus to textbox "RepairWhat" in my
subform.
All good and well.

I thought to simplify data entry I would introduce a pop-up calendar
for
each of my date fields - here is my code (with a great deal of help
from
the
web!).

Private Sub txtDateOrdered_Enter()

Calendar3.Visible = True
Calendar3.SetFocus

If Not IsNull(txtDateOrdered) Then
Calendar3.Value = txtDateOrdered.Value
Else
Calendar3.Value = Date
End If

End Sub

Private Sub Calendar3_Click()

txtDateOrdered.Value = Calendar3.Value
txtDateRequired.SetFocus
Calendar3.Visible = False
Calendar4.Visible = True

End Sub

Private Sub Calendar4_Click()
txtDateRequired.Value = Calendar4.Value
Forms![New Jobs]!NJSubform.Form!RepairWhat.SetFocus
'Calendar4.Visible = False

End Sub

The first two Subs - "Private Sub txtDateOrdered_Enter()" and
"Private
Sub
Calendar3_Click()" - works fine the calendar appears when the
"txtdateOrdered" is entered and a selection can be made. The focus
then
shifts to "txtDateRequired" and the second calendar "calendar4"
appears,
(I
know that from checking in design view).

When I now select a date from the calendar it is inserted but I get an
error
message saying :-
"Run-time error '2165':
You can't hide a control that has the focus"

I thought the line "Forms![New
Jobs]!NJSubform.Form!RepairWhat.SetFocus"
already had reset the focus?!?

Any suggestions?

Sandy
 
S

Sandy

Thanks Tony

I appreciate the references - both book and web - and I will certainly be
researching them.

Have a Good New Year

Sandy
 

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