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 / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

setting focus

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Coldeyes - 27 Mar 2005 16:29 GMT
I have an unbound control in the head of a form to select an item. I put a
code on the AfterUpdate property to pass the focus to a control in the body
of the form:

Me.DeliveryDate.Setfocus

I always get an error message that the focus cannot be passed to this
control. I changed "Me" to the full description of the form, no result. There
is no explanation why. Could u figure out what can be wrong?

Thanks in advance for your kind assistance.
Graham R Seach - 27 Mar 2005 16:42 GMT
It works fine for me! Is the control disabled?

In any case, I think you're better to use the Tab Order, to do it
automatically.

Open the form in design view, right-click and select Tab Order from the
context menu.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

>I have an unbound control in the head of a form to select an item. I put a
> code on the AfterUpdate property to pass the focus to a control in the
[quoted text clipped - 9 lines]
>
> Thanks in advance for your kind assistance.
Coldeyes - 27 Mar 2005 18:51 GMT
The control is enabled. The Tab order does not help since the unbound control
is in the head, the other control in the body section of the form.

In the meantime I realized that the problem is caused by the fact that there
is an event procedure on the GotFocus property of the control I want to pass
the focus to. This two contradict each other somehow. I might put the secont
procedure on another event following the GotFocus event but I do not yet know
which one. Any idea?

> It works fine for me! Is the control disabled?
>
[quoted text clipped - 23 lines]
> >
> > Thanks in advance for your kind assistance.
Graham R Seach - 28 Mar 2005 11:43 GMT
That depends on what that procedure does. What does it do?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

> The control is enabled. The Tab order does not help since the unbound
> control
[quoted text clipped - 38 lines]
>> >
>> > Thanks in advance for your kind assistance.
Coldeyes - 28 Mar 2005 14:07 GMT
Since we get forecasts of future orders for weekly deliveries the code looks
for the last date for the item in question and adds 7 days to the last date
so the user does not have to fill in the date field:

Private Sub DelDate_GotFocus()

Set db = CurrentDb
Set rs = db.OpenRecordset("Forecasts", dbOpenDynaset)
cond = Me.ProdSelect

With rs
.MoveLast
.FindLast "[ItemCode] ='" & cond & "'"
If .NoMatch = False Then
   felt = rs![DelDate]
   Me.DelDate = felt + 7
   Me.Quantity.SetFocus
Else
   Me.DelDate.SetFocus
End If
rs.Close
End With

End Sub

Thanks for your efforts.

> That depends on what that procedure does. What does it do?
>
[quoted text clipped - 46 lines]
> >> >
> >> > Thanks in advance for your kind assistance.
Larry G. - 28 Mar 2005 20:33 GMT
Add a secondary Else statement to set the Focus where you want in the line of
code you posted.

> Since we get forecasts of future orders for weekly deliveries the code looks
> for the last date for the item in question and adds 7 days to the last date
[quoted text clipped - 73 lines]
> > >> >
> > >> > Thanks in advance for your kind assistance.
Graham R Seach - 29 Mar 2005 11:30 GMT
I'm a little confused here. You first referred to the control as
"Me.DeliveryDate", then later as "Me.DelDate". That might be the problem.

In any case, why set the focus to a control that already has the focus?

As for your code, you might do away with the FindFirst method altogether by
being a bit mmore specific with your query:

   sSQL = "SELECT TOP 1 DelDate " & _
                  "FROM Forecasts " & _
                  "WHERE ItemCode = """ & Me.ProdSelect & """ " & _
                  "ORDER BY DelDate DESC"

   Set db = CurrentDb
   Set rs = db.OpenRecordset(sSQL, dbOpenSnapshot)
   If rs.AbsolutePosition > -1 Then
       'The record was found...

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

> Since we get forecasts of future orders for weekly deliveries the code
> looks
[quoted text clipped - 81 lines]
>> >> >
>> >> > Thanks in advance for your kind assistance.
 
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.