473,503 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

set focus on TextBox.

101 New Member
Hi,
My Project is in MS Access 2002.
In that I have one form which I am using for data entry.
Now in that I have some TextBoxes like
PalletNo,TotalPallets,ItemNo,LONo,PONo,BatchNo,Lot No,Cartons,PcsPerCarton etc.
Now when person scan a barcode from paper it will automatically enter Number(Like 24914) in first PalletNo TextBox.
In the AfterUpdate event of PalletNo TextBox I put some code so it will search the values of ItemNo,LONo,PONo,BatchNo,LotNo,Cartons,PcsPerCarto n etc and automatically put it in TextBoxes.and TotalPallets=1
Now again when person scan new barcode it will do the same thing as above for second PalletNo(Like 24915).But There is one more criteria that if ItemNo,LONo,PONo,BatchNo,LotNo,Cartons,PcsPerCarto n are same as it is for first PalletNo then it will TotalPallets=TotalPallets+1.and PalletNo=FirstPalletNo;SecondPalletNo(its value like this 24914;24915) and it will null the all details for second PalletNo so I can use it again.
Now when it null the values i put one more line
Me.PalletNo2.SetFocus

But its not working it will go to the next TabStop.So I have to again click on previous PalletNo and scan Barcode over There.
My Form is Unbound because I didn't Use Form Wizard to creat it.
Is this possible bcz of that its not working?

One more thing I want to know that ,
I put code in AfterUpdate event of PalletNo TextBox.Now after scaning the Barcode I have to press Tab or Click on another TextBox then it will enter the value Automatically in respective TextBoxes.Is that possible as soon as i scan the Barcode and it will enter the value in PalletNo TextBox then it will automatically search for Data as per search criteria and automatically add data in TextBoxes and cursor go to the next PalletNo.So that if I scan the First barcode then it will enter data and go to the next barcode and I have to only scan another barcode.I don't have to press Tab or Click on another TextBox again and again.

If u have any suggestion then plz give me.
Feb 27 '08 #1
4 18276
MindBender77
234 New Member
OK, wow, you got alot going on here. First, you can use an IF statement in the OnExit event of a textbox to catch null values. Example:

Expand|Select|Wrap|Line Numbers
  1. If isnull(TextBox1) = true then
  2. TextBox2 = ""  'Returns an empty textbox
  3. end if
  4.  
Lastly, you can use Dlookup to automatically populate all of you textboxes bases on a single barcode scan and no click or tabbing. On the OnExit event of your barcode textbox, you would do something like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Autopopulate()
  2. Dim Pnum as integer
  3.  
  4. Pnum = dlookup("[Field Name]", "YourTableName","[Field Name] = Textbox2")
  5. Pnum = Textbox8
  6. End Sub
  7.  
I sugggest doing a little research on the above mentioned stratagies,
Bender
Feb 28 '08 #2
missinglinq
3,532 Recognized Expert Specialist
Because of a quirk in Access, you cannot directly set focus to a control from that control's AfterUpdate event. Instead, you have to set focus to another control then set control back to the control in question:

Expand|Select|Wrap|Line Numbers
  1. Private Sub PalletNo_AfterUpdate()
  2.   Me.AnyOtherTextbox.SetFocus
  3.   Me.PalletNo.SetFocus
  4. End Sub
Linq ;0)>
Feb 29 '08 #3
billa856
101 New Member
I used the same thing in my coding.

The problem was that the text box I want to set focus to, already has the focus. Therefore, the command is not carried out. The way to handle this is to put a transparent command button immediately following the text box of interest in the tab order. Then a bit of code in its GotFocus event can set the focus back to the text box.

And Now its working Properly.
Thanks For Ur Replies.
Feb 29 '08 #4
davedenson
1 New Member
Thanks. I've been agonizing over this problem for days.
Dave Denson
Dec 14 '11 #5

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

Similar topics

17
3828
by: Neil Ginsberg | last post by:
OK, this is a stupid thing, but I can't seem to get this to work. I have a form with a subform (in continuous form view). A combo box on the main form has code in the AfterUpdate event which adds a...
0
2101
by: Jonas L | last post by:
Hi, I need to create a textbox which acts as a normal textbox but with the following extra requirements: 1) In-focus color, when the textbox gets focus the backcolor property of the textbox...
2
4938
by: zdavid | last post by:
Hi, I have a dialog box with a multiline textbox and three buttons. The obvious thing I'm suffering with is how to give focus to the textbox, so that when the dialogbox pops up, the user could...
4
3926
by: SJ | last post by:
Hi all, I have come across a weird problem when attempting to automatically set the focus in a vb.net form to a checkbox control... In my form I have (on a tab page in a tab control) several...
13
6896
by: Stefan | last post by:
hello, Just a sort of newbie question. How can i change the backcolor of the controls which have the focus (textbox/combobox/datetimepicker) and set it back to white when they lost focus. thanx...
5
8698
by: Tosch | last post by:
I have a usercontrol with a label, a textbox, a treeview, a grid and a couple of checkboxes. The usercontrol is hosted on a form together with a cancel and a accept button. This form is used to...
1
2495
by: Praveena.Alapati | last post by:
Hi, There is a tab control on a page with multiple tabs and handful of controls in each tab. The way it's rendered in html (like grid etc..) is in table format in tablerows and cells. On...
3
4907
by: hugo | last post by:
Hi, I have a function that I call from form fields using the OnKeyUp function to replace special caracters. Once this function has been called, it does not set the focus on the form field where...
2
1685
by: venkatarp | last post by:
Hi , I am facing one different problem. I have dropdown and textbox. After i selected drop down textbox should focus. But its disabled and not focussing......
5
13425
montzter
by: montzter | last post by:
Hi evryone, I'm having trouble in formatting the inputed data in the text box so that everytime user lost focus it will adjust its value to contain the format (#,####.##). ie user will input...
0
7199
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,...
1
6984
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
7453
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
5576
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
4670
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
3162
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
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1507
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 ...
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.