473,786 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

textbox populated from combobox not storing value

75 New Member
I am having a problem with my Access database, since I am new to this, I have no idea what is goign on????

okay here is the problem.

I have a database which has Meds tables, and has two fields.
1- Medication_Name
2-Concentration

On the form I have a combo box for Medication_Name (it has all the medication names form the Medication_Name field), and textbox for Concentration. I want my User when they pick the specific medication, the concentration textbox should get populated by itself. So, I was playing around with it, i got that part working, but the problem I am having is when the textfield for Concentration gets populated, its not saving in the main table. Is there a way we could do that?

please help me.

Thanks
Jun 7 '07 #1
14 3256
AccessIdiot
493 Contributor
What's the control source for the textbox?
Jun 7 '07 #2
pukhton
75 New Member
thanks for the reply. If i put the name of the field in the control source It will save in the table, but if i put this =DLookUp("Conce ntration","medq uery1") under control source I will the result, but it will not save into the table.

its kind of complicated to explain..


take a look of this too, it migh help you.

Private Sub Medication_Name _Change()
' DoCmd.OpenQuery "medquery1"
Me!Concentratio n.Requery
End Sub

and thats what i have under Query

SELECT Meds.Concentrat ion
FROM Meds
WHERE (((Meds.Medicat ion_Name)=[Forms]![MainTable1]![Medication Name]));
Jun 7 '07 #3
pukhton
75 New Member
please I need HELP regarding this..
Jun 11 '07 #4
FishVal
2,653 Recognized Expert Specialist
thanks for the reply. If i put the name of the field in the control source It will save in the table, but if i put this =DLookUp("Conce ntration","medq uery1") under control source I will the result, but it will not save into the table.

its kind of complicated to explain..


take a look of this too, it migh help you.

Private Sub Medication_Name _Change()
' DoCmd.OpenQuery "medquery1"
Me!Concentratio n.Requery
End Sub

and thats what i have under Query

SELECT Meds.Concentrat ion
FROM Meds
WHERE (((Meds.Medicat ion_Name)=[Forms]![MainTable1]![Medication Name]));
Something like this.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Medication_Name_AfterUpdate()
  3.  
  4.     Me!Concentration = DLookup("[Concentration]", "[Meds]", _
  5.         "[Medication_Name] = '" & Me![Medication_Name]) & "'"
  6.  
  7. End Sub
  8.  
  9.  
Jun 11 '07 #5
pukhton
75 New Member
can u plz explain this little bit more, because i am still not getting the right answer.
Jun 11 '07 #6
FishVal
2,653 Recognized Expert Specialist
can u plz explain this little bit more, because i am still not getting the right answer.
This sub is fired on AfterUpdate event in your combo and change the value of the text box to Concentration that matches Medical_Name in you table.

Assumed that
1) the type of Meds.Medical_Na me is text
2) combo Medication_Name .BoundColumn is a column corresponding to Meds.Medical_Na me

Take into account that DLookup function returns the first matching value only.

Good luck.
Jun 11 '07 #7
pukhton
75 New Member
This sub is fired on AfterUpdate event in your combo and change the value of the text box to Concentration that matches Medical_Name in you table.

Assumed that
1) the type of Meds.Medical_Na me is text
2) combo Medication_Name .BoundColumn is a column corresponding to Meds.Medical_Na me

Take into account that DLookup function returns the first matching value only.

Good luck.

I just copy this into the Medication_Name "after update event" but i am getting this error, i am really sorry if i am getting pain the neck

It says Microsoft Access cant find the field 'Medication_Nam e" reffered to in your expression.
I am sure I do have this field name Under Meds table.

Any help please???
Jun 11 '07 #8
FishVal
2,653 Recognized Expert Specialist
I just copy this into the Medication_Name "after update event" but i am getting this error, i am really sorry if i am getting pain the neck

It says Microsoft Access cant find the field 'Medication_Nam e" reffered to in your expression.
I am sure I do have this field name Under Meds table.

Any help please???
I can suggest you the following another way.

1) change in design view the following Medication_Name combo properties
.RowSource="SEL ECT Meds.Concentrat ion, Meds.Medication _Name FROM Meds; "
.BoundColumn=2
.ColumnCount=2
.ColumnWidths=0 ;10

2) write another AfterUpdate event handler

Expand|Select|Wrap|Line Numbers
  1. Private Sub Medication_Name_AfterUpdate()
  2.  
  3.     With Me.Medication_Name
  4.         Me.Concentration = .Column(0, .ListIndex)
  5.     End With
  6.  
  7. End Sub
  8.  
I've checked this. It works fine.

Good Luck.

PS. If your combo is not bound to table, the code will be even more simple.
Jun 11 '07 #9
pukhton
75 New Member
I can suggest you the following another way.

1) change in design view the following Medication_Name combo properties
.RowSource="SEL ECT Meds.Concentrat ion, Meds.Medication _Name FROM Meds; "
.BoundColumn=2
.ColumnCount=2
.ColumnWidths=0 ;10

2) write another AfterUpdate event handler

Expand|Select|Wrap|Line Numbers
  1. Private Sub Medication_Name_AfterUpdate()
  2.  
  3.     With Me.Medication_Name
  4.         Me.Concentration = .Column(0, .ListIndex)
  5.     End With
  6.  
  7. End Sub
  8.  
I've checked this. It works fine.

Good Luck.

PS. If your combo is not bound to table, the code will be even more simple.
sorry I tried that, but still nothing...i am sure its me. I am not sure how to fix this crap. I will appreciate it if i can send yout the file on your email id, take a look, and see what am i doing wrong?

thanks
let me know plz.
Jun 11 '07 #10

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

Similar topics

5
3082
by: Steve | last post by:
I have an unbound combobox in the form header of a continuous form. The selection in the combobox sets the where clause in a querydef which determines QryPFrmInventoryManagement. The following code is in the afterupdate event of the combobox: Me.RecordSource = "QryPFrmInventoryManagement" Me!ItemCount = Me.RecordsetClone.RecordCount & " Items" MsgBox Me.RecordsetClone.RecordCount & " Items"
2
2742
by: Zlatko Matiæ | last post by:
I have several forms hierarchycaly nested in each other (form/subform/subform/subform....). The final form is "continous form", while parent forms are single forms through which navigation was performed by navigation buttons. Now I want to enable navigation through records both by navigation buttons and COMBOBOXES. Therefore I added comboboxes besides textboxes. Let's suppose that txtAAA is textbox and cbxAAA is cmbobox. My aproach was...
0
1961
by: Ken Arway | last post by:
Using .Net framework 1.1 I've got a Windows Forms application with a tab control having four tab pages. TabPage4 contains a Combobox and a TextBox, which are bound to the same XML file as a DataSource. The ComboBox displays the values from the "name" column of the DataSource and the TextBox displays the "location" value. The two controls are co-ordinated by a BindingManagerBase (bmInfo). When a different "name" item in the ComboBox is...
11
7764
by: Joe | last post by:
Hello All, I have an ASP.NET page with one Textbox (SearchTextBox) and one ImageButton (SearchButton) server controls. The user can type search text in SearchTextBox and click SearchButton and the web server performs a database query and displays the results. All of this works fine. I want the user to be able to press the Enter key while the cursor is still in SearchTextBox and have the SearchButton.Click event fire (thus performing...
2
19875
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
2
2506
by: Scott Emick | last post by:
I cannot remember how to enable the vertical scrollbar in my textbox for which I've added combobox controls to dynamically. I have the vertical scrollbar turned on, but it is greyed out and I cannot remember how to 'enable' it. Thanks -- Scott Emick
1
3237
by: billypit | last post by:
Hi, I am totaly new to MS Access. I have one form in MS Access in which i want that whenever i select an item from combobox then in the textbox on the same form or subform i want value from table based on selection from combobox. like in my table there two fields ID,name 1 billy 2 sandy
7
4893
by: creative1 | last post by:
hi, I have a simple query. I have a dynamic combobox when I select one value fromt he combobox; on click a function is called that display the value of the combobox(i.e not same as text list of combobox) in textbox on the form. I want to display the selected entry(not the value) of the combobox in another text box. How I can do that this is what I already have function getvalue(form) { ...
2
3371
by: dibblm | last post by:
I'll start this hopefully simple and add code where needed or requested. Im using a combobox that bound to a DataSet. The Dataset retreives it's values from SQL. I can retreive the values fine. However only displaying (1) Column. Which is fine. Here's where it gets complicated for me. The dataset has 2 other columns that get filled. I need the resulting columns to be sent to text boxes when I select a value from the combobox. ...
0
9650
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
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,...
1
10110
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
9962
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
8992
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6748
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
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

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.