473,654 Members | 3,011 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,TotalP allets,ItemNo,L ONo,PONo,BatchN o,LotNo,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,PON o,BatchNo,LotNo ,Cartons,PcsPer Carton 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,PON o,BatchNo,LotNo ,Cartons,PcsPer Carton are same as it is for first PalletNo then it will TotalPallets=To talPallets+1.an d PalletNo=FirstP alletNo;SecondP alletNo(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.Se tFocus

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 18332
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
3849
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 record to the subform (based on the value of the combo box) and requeries the subform control. I want the focus to return to the combo box on the main form when it's done, but I can't get it to do so if the user enters a value and presses Enter...
0
2117
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 should be set to a, selectable, in-focus color. 2) Out-of-focus color, when the textbox loses focus the backcolor property of the textbox should be set to a, selectable, out-of-focus color.
2
4951
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 immediately start typing without having to click in the textbox. I tried textBox.Focus(), textBox.SelectAll() with no success... The tabindex of the textbox is set to 0, which should mean that the textbox would have the focus when the dialogbox is...
4
3944
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 textboxes and a checkbox. The behaviour I want from my app is as follows:- When the textbox (which is prior in tab order to the tab control) has been filled with a certain length of text by the user, the focus is
13
6932
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 in advance Stefan
5
8710
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 search records in a database. On several forms in my application I show (modal) this form to search records. Everytime I show the form I want the focus to be on the textbox on the usercontrol. This works the first time I display the form. But...
1
2510
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 clientside, on form validation in javascript, I would like to set focus on to one of the tabs and set the focus to the control on that tab.
3
4920
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 I have called the function from. What happens : I laod a EDIT page with a html form on it and fill in the fields with
2
1691
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
13472
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 1111.1 it will immediately be converted to 1,111.10 as its value. I've tried using this code in every lost focus: textbox.text = round(val(textbox.text)), 2) but the problem with this is I am not getting the comma and if the user enters an exact...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4149
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
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 we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.