UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> SetFocus to a control    
 
   
zero_cool
post Aug 10 2005, 11:07 PM
Post #1

UtterAccess Addict
Posts: 133
From: UK



Hey everybody,
I have a IF function that runs on my form. After END IF I have the command Me.PeriodFrom.SetFocus

When the code runs however, the focus is not returned to this control and instead passes to the next one in the tab list. Is there some rule about where the setfocus command must be placed that I don't know about?

Thanks in advance.
Go to the top of the page
 
+
freakazeud
post Aug 10 2005, 11:14 PM
Post #2

UtterAccess VIP
Posts: 31,413
From: NC, USA



Hi,
what code are you using. Where are you fireing it, where is the focus at that moment, where do you want the focus to go to...
Maybe you can clarify those things so we get a better idea of what it is you are trying to achieve.
HTH
Good luck
Go to the top of the page
 
+
zero_cool
post Aug 11 2005, 05:36 PM
Post #3

UtterAccess Addict
Posts: 133
From: UK



Private Sub PeriodFrom_LostFocus()

If IsNull(Me.ExpenseID) = True Then
MsgBox ("You must enter a Period From date before proceeding")
End If

Me.PeriodFrom.SetFocus

End Sub

That is an extract of the code which should answer most of your questions. I did have Me.PeriodFrom.SetFocus within the IF function. I was moving it around to try and understand what the best sequence was.
Go to the top of the page
 
+
JayNoelOlimpo
post Aug 11 2005, 05:41 PM
Post #4

UtterAccess VIP
Posts: 7,990
From: Philippines



Hi;

Use Before Update Event procedure ...

CODE
If IsNull(ExpenseID) Then
    MsgBox ("You must enter a Period From date before proceeding")
    Cancel = True
End If


HTW.
Go to the top of the page
 
+
zero_cool
post Aug 14 2005, 08:38 PM
Post #5

UtterAccess Addict
Posts: 133
From: UK



Hi,
I tired entering that code and it did not really do what i wanted it to.

I have a mainform (with the ExpenseID on) and a subform. When the user enters a date (in Period From) the expense ID is generated. If they move into the subform without a expense ID being generated then it generates an error because there is no link. I want to prevent that by not letting the focus move from the Period From box until a date has been entered.

Hope that makes sense.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 18th June 2013 - 10:21 PM