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. - Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
-
If KeyCode = 27 Then
-
DoCmd.CancelEvent
-
KeyCode = 0
-
Forms!Fis_OrderICNSF.SetFocus
-
Forms!Fis_OrderICNSF!Item_Lookup.SetFocus
-
End If
Any suggestions pls
8 1926
As always, please describe what is happening currently. Does the code even run?
Sorry, it does not set the focus back to the item_lookup field in the subform, when it clears the row after pressing Escape
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.
NeoPa 32,556
Expert Mod 16PB
Please also explain how the various items in your question relate to each other. - What is the name of the main form involved?
- Is the code running from the main form or the sub-form?
- What is the name of the subform control as well as the form contained within it?
- 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).
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 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.
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.
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).
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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
|
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...
|
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,...
|
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.
...
|
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
...
|
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...
|
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...
|
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...
|
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,...
|
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$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
|
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...
| |