Set Focus from subform to main form (1 Viewer)

aliazadahmed

New member
Local time
Today, 07:30
Joined
Jul 12, 2018
Messages
6
Dear all,

I have a big problem which is the focus issue form subform into main form,
my main form name (sell)
my subform name (subsell)
in main form I have combobox for reading barcode of items and insert into table which created the subform from it,
On load I set focus on combobox and is working well as first entry but after that the focus will go to subform and I can't insert new data into combobox until I select the combobox again,
I used many event procedure,expression in subform to set focus but with no luck :banghead:
Any help please...
 

isladogs

MVP / VIP
Local time
Today, 05:30
Joined
Jan 14, 2017
Messages
18,218
Change the tab order in the main form so that another main form control is next in the tab order instead of the subform
OR add code in the after update event of the combo to set the focus to another main form control
 

aliazadahmed

New member
Local time
Today, 07:30
Joined
Jul 12, 2018
Messages
6
Dear ridders,

I checked tab order on my main form there are not contain any field of sub form,
I used expression on current event of main form like this:
=[Forms]![Sell]![txtmainsellcomboicode].[setfocus]

but with no luck,
Please note that when I click on combobox and select form combobox it is ok still focus but when I insert data into combobox with barcode reader it will find data on combobox and insert it into table after that the focus go to subform,

I need your help please...
 

isladogs

MVP / VIP
Local time
Today, 05:30
Joined
Jan 14, 2017
Messages
18,218
The subform itself is a control on the main form
Presumably it's currently next on the tab order after your combo
So the focus goes to the first control on the subform.

The form current event is no use.
As already stated, use the combo after update event and add a one like
Code:
me.someothercontrol.setfocus
 

aliazadahmed

New member
Local time
Today, 07:30
Joined
Jul 12, 2018
Messages
6
Thanks ridders,

I sorted the tab order and set the sub form in last order now the focus not go to subform but still go to button on the main form,

what I need is to set focus on the same combobox for entering data until I manually click on print button or any other control on the main form,
I entered after update event of combobox:
me.setfocus
but still go to another control can you solve my problem?
this form that I tell you is for marketting system and the combobox is for cashier to sell things,
Please help me
 

isladogs

MVP / VIP
Local time
Today, 05:30
Joined
Jan 14, 2017
Messages
18,218
Access is designed to move to another control.
You can't use Me.SetFocus
You could try putting the same combobox name there but I doubt it will work.
Alternatively, you could add code t your button got focus event to send the focus back to the combo
BUT that could cause an infinite loop if you're not careful. Not recommended!!
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 00:30
Joined
Feb 19, 2002
Messages
43,266
what I need is to set focus on the same combobox for entering data until I manually click on print button or any other control on the main form,
That implies that you want to keep typing over the value you just entered. Sorry but I can't make sense out of the request. Can you tell us what you are trying to accomplish by not leaving the first field on the form?
 

Users who are viewing this thread

Top Bottom