473,473 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Add text of two unbound text boxes into one field.

16 New Member
i want to add text from two unbound text box into one field, when i write an expression for this, the result appear in the form but the field table remain empty.
Please suggest a solution.
May 12 '18 #1
6 1316
NeoPa
32,556 Recognized Expert Moderator MVP
If it's an expression then, by definition, it's not bound to any table.

If you want a value in the table (.RecordSource) to be updated then you need to bind a control to the relevant field and update the value whenever either of the two unbound controls is updated. Use the .AfterUpdate() events for this.
May 12 '18 #2
Jugnu
16 New Member
Thanks NeoPa,
But i am completely new to VBA and don't know what to write in after update event.
Will you please guide how to do this.
I have a field in database table named as
Home address and i have two unbound boxes in my form1 named as city and pin number.
I want enter data of city and pin number boxes in to home address field. Please guide me with a VBA code how to do this.
Thanks for your kind reply. ��
May 18 '18 #3
NeoPa
32,556 Recognized Expert Moderator MVP
Well, I should start off by saying that this is really a site for developers to help each other. Simply asking for the work to be done for you is generally frowned upon.

However, this once I'll show you how to manage it. You will be expected to be able to cope with the basics in future though. Possibly visit Microsoft Access Tutorials (Strive4Peace) and learn the basics first if you need more help.

Here's another point. In order to be able to help I need to know what you're working with as far as control names go and various other basic information required for your question to make proper sense. For now I'll assign my own names and hope you can recognise what's what. If you ever write another question make sure you do a better job of explaining the situation fully. As you haven't included any such information I will also have to assume that you're working in India and the PIN you refer to is the six-digit PIN they use there.

Anyway, for your situation you first need to ensure that the two unbound controls properly reflect the correct data each time a record is made the current one. This requires them to be set in the Form's Current event procedure ([txtHomeAddress] may be invisible but must exist. If visible then it should be locked.) :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     With Me
  3.         .txtCity = Null
  4.         .txtPIN = Null
  5.         If .txtHomeAddress Like "* ######" Then
  6.             .txtCity = Trim(Left(.txtHomeAddress, Len(.txtHomeAddress) - 6)
  7.             .txtPIN = Right(.txtHomeAddress, 6)
  8.         ElseIf .txtHomeAddress Like "######" Then
  9.             .txtPIN = .txtHomeAddress
  10.         ElseIf .txtHomeAddress > "" Then
  11.             .txtCity = Trim(.txtHomeAddress)
  12.         End If
  13.     End With
  14. End Sub
Next you need to make sure that if either is updated then the updated value is applied back into Me.txtHomeAddress appropriately.
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtCity_AfterUpdate()
  2.     With Me
  3.         .txtHomeAddress = Trim((.txtCity + " ") & .txtPIN)
  4.     End With
  5. End Sub
  6.  
  7. Private Sub txtPIN_AfterUpdate()
  8.     With Me
  9.         .txtHomeAddress = Trim((.txtCity + " ") & .txtPIN)
  10.     End With
  11. End Sub
May 18 '18 #4
NeoPa
32,556 Recognized Expert Moderator MVP
Another very important thing you should understand if you're ever working with databases is Database Normalisation and Table Structures. Storing an address as a single field and then trying to separate it out when working with it is really not a sensible approach. If you need the data to be separate then it shouldn't be stored together. A proper design helps you avoid all the unnecessary complications required when you do it the wrong way.
May 18 '18 #5
Jugnu
16 New Member
Thanks NeoPa.
It completely works for me.
You really such a genius ��
May 24 '18 #6
NeoPa
32,556 Recognized Expert Moderator MVP
I'm happy that I helped, but don't forget the other point about not using such a design in the first place.

Your mother would have warned you all about that when you were very young - if she'd known anything about databases ;-)
May 24 '18 #7

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

Similar topics

7
by: Aravind | last post by:
Hi folks. I have 2 forms, frmBorrow and frmHistory frmBorrow has an unbound multi-column combo box (cboMember) and 7 unbound text boxes (MemNo, MemName, MemIC, MemType, CourseFaculty, Borrow,...
3
by: flunn | last post by:
I'm a beginner with php. I'm trying to learn it so I can make quizzes and tutorials for my English as a Second Language site. I'm trying to make a form that does the following: (1) the user...
11
by: amanda27 | last post by:
I have a form and there are some text boxes that show a score depending on what someone picks in the drop down next to that box. I did this part with some coding and therefore, for example if they...
11
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command...
7
by: HSXWillH | last post by:
I am designing an inventory system and am stuck on a potential problem. I have a table of Stock_Catalog containing the following fields: Stock_ID (random autonumber), Full_Desc, Serial, Auto,...
2
topher23
by: topher23 | last post by:
Disclaimer: I've already come up with a solution for this issue, but I thought I'd post it in the hope that it could help someone else and on the off chance that someone has another solution. I...
1
by: gorstiedaghost | last post by:
Hi, atm i have a peice of code that will open microsoft word, and then copy text that it inside two speech marks. But instead of copying the text from the speech marks, i want to change the code to...
7
by: aannll | last post by:
hiiii i have form(Main form) that contain textboxes(f1,f2) and a button (f3) when enter values to text boxes and click the button i want the values saved in fields(Passwords,Names) that Exists in...
6
by: jalbright1957 | last post by:
I have a continuous form set as a modal type. In the detail section of the form I have the following bound fields: RecordNumber, JobName & ContractorsBidding. The header of the form contains text...
9
by: 3ari3 | last post by:
Hello all, I am trying to filter a basic form with multiple unbound textboxes. Right now I have separate boxes for each criteria (which is great for what we need, however I was asked to allow...
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
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...
0
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
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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
muto222
php
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.