473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Set Focus Not working on a form

I have a form that onlost focus of txtBadgID executes the following
code:

Private Sub txtBadgeID_AfterUpdate()

strEmpID = DLookup("[id]", "tblEmployee", "[BadgeID] =
forms!frmSave!checkedoutby")
If IsNull(strEmpID) Then
MsgBox "Badge Not Found, Enter Employee then Proceed!",
vbCritical, "Equipment Check Out"
Me.txtBadgeID.Value = ""
Me.txtBadgeID.SetFocus
Exit Sub
End If
Me.Employee_ID.Value = strEmpID
Me.Equipment_ID.Value = Forms!frmScanLocation.txtEquipmentID
Me.CheckedOut.Value = True
DoCmd.Close
Forms!frmScanLocation.Visible = True
Forms!frmScanLocation.txtScanLoc.Value = ""

End Sub

My problem is that txtBadgID is not gaining focus if strEmpID isNull
(the first if Statement. Any Ideas? It then line
me.txtBadgeID.Setfocus should work... The line me.txtBadgeID.Value = ""
does in face clear the text box from all text.. Any thoughts?

Thanks,

Dave

Dec 22 '06 #1
2 3896
(1) For the record, the LostFocus and AfterUpdate events are not the same.

(2) If the Control never _gets_ the focus, you are going to have to put your
code somewhere other than one of that Control's events.

Larry Linson
Microsoft Access MVP

<st********@hotmail.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
>I have a form that onlost focus of txtBadgID executes the following
code:

Private Sub txtBadgeID_AfterUpdate()

strEmpID = DLookup("[id]", "tblEmployee", "[BadgeID] =
forms!frmSave!checkedoutby")
If IsNull(strEmpID) Then
MsgBox "Badge Not Found, Enter Employee then Proceed!",
vbCritical, "Equipment Check Out"
Me.txtBadgeID.Value = ""
Me.txtBadgeID.SetFocus
Exit Sub
End If
Me.Employee_ID.Value = strEmpID
Me.Equipment_ID.Value = Forms!frmScanLocation.txtEquipmentID
Me.CheckedOut.Value = True
DoCmd.Close
Forms!frmScanLocation.Visible = True
Forms!frmScanLocation.txtScanLoc.Value = ""

End Sub

My problem is that txtBadgID is not gaining focus if strEmpID isNull
(the first if Statement. Any Ideas? It then line
me.txtBadgeID.Setfocus should work... The line me.txtBadgeID.Value = ""
does in face clear the text box from all text.. Any thoughts?

Thanks,

Dave

Dec 23 '06 #2
Try replacing Me.txtBadgeID.SetFocus with Cancel = True

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: JCO | last post by:
I have a text box, on my form that I cant get the focus on. I'm using it as shown: <head> <body onload=document.getPassword.txtPasswordName.focus()> </head> Where getPassword is the form &...
4
by: Scott Navarre | last post by:
Hi, I have Red Hat 8.0 and have the default Mozilla browser that comes with it. I am programming in javascript and have come across something problematic. Given the following code: <HTML>...
5
by: tshad | last post by:
I have a date validation function that I want to stay at the object I am validating if there is a Validation error, but it always goes to the next object. The Javascript: function...
2
by: Mystery Man | last post by:
We have an MDI application that is not setting always setting focus to the newly corrected MDI. It is creating the form and it is the topmost but it does not have focus. The code we are using to...
3
by: Saurabh Sharma | last post by:
Hi I found a particular process that is running on my machine. I have th eprocess ID for that how to set Focus to that Process Regards Saurabh
2
by: Sridhar | last post by:
Hi, I have a question. I have created a user control which contains a textbox and a button. we will enter some search word in the textbox and hit the button. Then we will get a pop-up with the...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
1
by: prabuinet | last post by:
hi, I added a form as a control on another form. After adding i want the embedded form to have focus. I tried all combinations but its not working.. Do any one know how to do this. ...
6
by: msg2ajay | last post by:
hi, i have tried like this ... but i am not able to continue with this code... any bady hav idea on this??? <html> <head> <script language="JavaScript"> function checkme(strVal){
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.