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.
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.