473,385 Members | 1,863 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,385 software developers and data experts.

Keycode and setfocus issue

547 512MB
I have a problem to reset the focus to a specific field in a subform, when i press the escape button on the keyboard using the following vba. This field is a lookup field.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2. If KeyCode = 27 Then
  3.         DoCmd.CancelEvent
  4.          KeyCode = 0
  5.      Forms!Fis_OrderICNSF.SetFocus
  6.       Forms!Fis_OrderICNSF!Item_Lookup.SetFocus
  7.         End If
Any suggestions pls
Jan 17 '13 #1
8 1926
TheSmileyCoder
2,322 Expert Mod 2GB
As always, please describe what is happening currently. Does the code even run?
Jan 17 '13 #2
neelsfer
547 512MB
Sorry, it does not set the focus back to the item_lookup field in the subform, when it clears the row after pressing Escape
Jan 17 '13 #3
TheSmileyCoder
2,322 Expert Mod 2GB
TheSmileyCoder
Does the code even run?
Please make sure to answer those questions asked for you. Otherwise you will find that people rapidly loose interest in the thread, if they have to drag the required information from you.
Jan 17 '13 #4
NeoPa
32,556 Expert Mod 16PB
Please also explain how the various items in your question relate to each other.
  1. What is the name of the main form involved?
  2. Is the code running from the main form or the sub-form?
  3. What is the name of the subform control as well as the form contained within it?
  4. What is the name of the control that focus is on when you tested this code?

With all that information we will be in a position to answer your question. Having it in your question post already is always a very good idea.

PS. If [Fis_OrderICNSF] is the name of your sub-form's form, then the Forms!Fis_OrderICNSF reference will not work (See Referring to Items on a Sub-Form).
Jan 17 '13 #5
neelsfer
547 512MB
Apologies
main form is OrderingF
Sub-form = Fis_OrderICNSF
main control : Item_Lookup
Focus stays in "quantity" field after Escape is pressed and row cleared

What i would like to do is when i press Escape on the keyboard after the row had been added, the row must be cleared and the focus must return to the original field called "Item_lookup, where i searched for the item to be captured. Currently when an Item has been added, the focus goes to the next field called "Quantity" in the subform and it stays there even after the row has been cleared(deleted).
Hope it is clearer now.
thx

Attached Images
File Type: jpg Capture.jpg (41.7 KB, 277 views)
Jan 18 '13 #6
NeoPa
32,556 Expert Mod 16PB
That is much clearer now Neels, but you've missed out two items requested. I doubt you'll catch me now for a few hours, but with that extra information many experts will be able to help, and I'll be looking at it again when I next can too.
Jan 18 '13 #7
Rabbit
12,516 Expert Mod 8TB
If it's a subform, it doesn't get added to the Forms collection. Therefore you can't reference a subform using Forms!subFormName.controlName. You need to use Forms!mainForm!subFormControlName.Form.controlName. You may or may not need that Form reference, I can't remember off the top of my head, try both.
Jan 18 '13 #8
NeoPa
32,556 Expert Mod 16PB
Rabbit:
You need to use Forms!mainForm!subFormControlName.Form.controlName . You may or may not need that Form reference, I can't remember off the top of my head, try both.
To clarify that point, as the control on the form (any form) is no part of a SubForm control, something must specify that it is the Form object that is the next part of the reference. this can be done explicitly (...subFormControlName.Form.controlName) or by inference (...subFormControlName!controlName).
Jan 19 '13 #9

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

Similar topics

2
by: Marcia Gulesian | last post by:
The following code suppresses the 'enter' key, when run in I.E. 5.5 or later (Windows) but not when run in Safari (Mac) <body onkeypress="javascript:keysuppress(event)" > function...
5
by: Girish | last post by:
I have TWO submit buttons of type IMAGE on my asp form. This renders as <input type="image">. I need to be able to eble the ENTER button for both buttons. Yes, I know that for the input type...
2
by: bill | last post by:
I have the following user control in my project simply for setting focus to a control: Public Class SetFocus Inherits System.Web.UI.UserControl
4
by: jibran | last post by:
Hello. I have wrapped the DataGrid control with my own class (SmartDataGrid) adding some necessary functionality. My current webform has 2 SmartDataGrids. The first is populated by selected...
3
by: Paul Gorodyansky | last post by:
Hi, I have function that works via onkeypressed - for example, what to catch when a user presses a punctuation symbol such as '.' So I check keyCode for that - works just fine in Opera 8,...
5
by: technocraze | last post by:
Hi guys, i tried using the AddRecord command (Record operation - Add New Record) provided by MS Acess but the new record is not been appended to the table but instead it has been overwritten. ...
5
agroover
by: agroover | last post by:
I can't seem to figure out how to get rid of the errors. I recieve the following error when I leave the Grade.SetFocus in my code... Microsoft Access can't move the focus to the control Grade ...
0
by: Andy_Khosravi | last post by:
I'm having issues with updates being blocked due to some sort of record locking issue. The error does not occur consistently, so I've had a hard time nailing it down. It does happen enough to cause...
9
by: sunita jadhav | last post by:
my question is if i type in html textbox on key press event suppose i type 12345 values in textbox then i delete or edit any value of text box suppose i edit 3 and i insert the value 6 at 3 but i...
18
by: Marilyth | last post by:
I am using Windows XP and Access 2003. I have searched through my HUGE book & the questions here, and found some items that "might" help, but unsure still. I am still getting versed on Access. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
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...

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.