473,471 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

In Access, how to use SetFocus within the LostFocus procedure (for same control)

4 New Member
hi

in access 2003 how we can use the setfocuse property(we have to lostfocuse from one field with in that we have to setfocuse in same field)
i am using this code but not setfocuse to same field (this is my problem please give proper gidence for this problem) :-

Description about this code:-

Sex field is one combo box in two options male-1;female-2
IND_APPL is one combo box here options are applicable-1;not applicable-0

Expand|Select|Wrap|Line Numbers
  1. Private Sub IND_APPL_LostFocus()
  2. If Sex.Value = 1 And IND_APPL.Value = 0 Then
  3. Form_PHMRC.SIB1.SetFocus
  4. IND_Line.SetFocus
  5. Else
  6. If Sex.Value = 2 And IND_APPL.Value = 1 Then
  7. IND_N20.SetFocus
  8. Else
  9. MsgBox ("CHECK WITH SEX")
  10. IND_APPL.SetFocus
  11. End If
  12. End If
  13. End Sub
here every thing ok but this statement IND_APPL.setfocuse not respond properley
while giving this options Sex.value = 1 and IND_APPL.value = 1 and
Sex.value = 2 and IND_APPL.value = 0 (ELSE block)
it show msgbox CHECK WITH SEX properely
but it is not setfocus to IND_APPL this field (it is setfocuse to next field)

please give to me proper gidence how i will over come this problem
Mar 29 '07 #1
3 3456
pureenhanoi
175 New Member
hi

in access 2003 how we can use the setfocuse property(we have to lostfocuse from one field with in that we have to setfocuse in same field)
i am using this code but not setfocuse to same field (this is my problem please give proper gidence for this problem) :-

Description about this code:-

Sex field is one combo box in two options male-1;female-2
IND_APPL is one combo box here options are applicable-1;not applicable-0

CODE:-

Private Sub IND_APPL_LostFocus()
If Sex.Value = 1 And IND_APPL.Value = 0 Then
Form_PHMRC.SIB1.SetFocus
IND_Line.SetFocus
Else
If Sex.Value = 2 And IND_APPL.Value = 1 Then
IND_N20.SetFocus
Else
MsgBox ("CHECK WITH SEX")
IND_APPL.SetFocus
End If
End If
End Sub

here every thing ok but this statement IND_APPL.setfocuse not respond properley
while giving this options Sex.value = 1 and IND_APPL.value = 1 and
Sex.value = 2 and IND_APPL.value = 0 (ELSE block)
it show msgbox CHECK WITH SEX properely
but it is not setfocus to IND_APPL this field (it is setfocuse to next field)

please give to me proper gidence how i will over come this problem
Try this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub IND_APPL_Validate(Cancel as Boolean)
  2. If condition=TRUE Then
  3.       Cancel = False
  4.       onotherTextBox.SetFocus
  5. Else
  6.       Cancel = TRUE
  7. End If
  8. End Sub
  9.  
You should set Cancel variable to TRUE to hold the focus at the same Text Field and to FALSE to allow focus to onother control.
Mar 29 '07 #2
Killer42
8,435 Recognized Expert Expert
...You should set Cancel variable to TRUE to hold the focus at the same Text Field and to FALSE to allow focus to onother control.
Good idea. However, you don't need to explicitly set it to False - that is the default value.
Mar 29 '07 #3
vijaydiwakar
579 Contributor
its not a good practise to use lostfocus
Try Validate Event
Mar 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Vincent Yang | last post by:
I'm using Access 2002. My database is in Access 2000 format. I'm designing a form to collect responses to a 40-item questionnaire. I can fit four list boxes on a screen, so I plan to have 11 tab...
2
by: vooose | last post by:
Does anyone know the difference between these two? The doc for LostFocus says 'Occurs when the control loses focus.' whereas for Leave it says 'Occurs when the input focus leaves the control'...
0
by: Scott McChesney | last post by:
All - I am in the process of developing a custom control that mimics the Office 2003 "Inbox" as closely as possible. After a great deal of frustrating work trying to do a heavily custom-drawn...
0
by: Greg | last post by:
I'd like to know which contol the focus of a cell in a datagrid is being lost to. Querying ActiveControl.Name within the LostFocus event gives me a blank string, instead of the name of a button I...
1
by: Vincent | last post by:
I keep receiving the above error message in Microsoft Access when I attempt to click on one of the text boxes on my form. I have done some searching and came across a couple of posts that stated...
6
by: Carmon | last post by:
I am using Managed C++ with a CFormView and a MaskedTextBox and have used MAKE_DELEGATE to sink the LostFocus event of this control. I have other events I've sinked off this control and they all...
0
by: bindurajeesh | last post by:
What is comparable to setfocus and lostfocus of vb6 in vb.net
14
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user...
0
by: vtelebyteM | last post by:
i have 1)User control with one MSFlexGrid on it 2)Form to place user control 3)Some form's own control i dont know how many controls are there under form i have to place them in grid columns...
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
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,...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.