Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / December 2007

Tip: Looking for answers? Try searching our database.

Calendar control part 2

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sandy - 30 Dec 2007 13:49 GMT
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
Hunter57 - 30 Dec 2007 16:13 GMT
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".
[quoted text clipped - 57 lines]
>
>  
Sandy - 30 Dec 2007 17:43 GMT
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
>
[quoted text clipped - 87 lines]
>>
>> Sandy
Hunter57 - 30 Dec 2007 17:58 GMT
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

> Hi Patrick,
>
[quoted text clipped - 106 lines]
> >>
> >> Sandy
Sandy - 30 Dec 2007 18:19 GMT
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

> Hi Sandy,
>
[quoted text clipped - 149 lines]
>> >>
>> >> Sandy
Hunter57 - 31 Dec 2007 02:33 GMT
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

> Hi Patrick
>
[quoted text clipped - 160 lines]
> >> >>
> >> >> Sandy
Tony Toews [MVP] - 30 Dec 2007 20:48 GMT
>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
Signature

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/

Sandy - 31 Dec 2007 10:54 GMT
Thanks Tony

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

Have a Good New Year

Sandy

>>I thought to simplify data entry I would introduce a pop-up calendar for
>>each of my date fields -
[quoted text clipped - 21 lines]
>
> Tony
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.