473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

textbox populated from combobox not storing value

75
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 3233
AccessIdiot
493 256MB
What's the control source for the textbox?
Jun 7 '07 #2
pukhton
75
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("Concentration","medquery1") 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!Concentration.Requery
End Sub

and thats what i have under Query

SELECT Meds.Concentration
FROM Meds
WHERE (((Meds.Medication_Name)=[Forms]![MainTable1]![Medication Name]));
Jun 7 '07 #3
pukhton
75
please I need HELP regarding this..
Jun 11 '07 #4
FishVal
2,653 Expert 2GB
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("Concentration","medquery1") 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!Concentration.Requery
End Sub

and thats what i have under Query

SELECT Meds.Concentration
FROM Meds
WHERE (((Meds.Medication_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
can u plz explain this little bit more, because i am still not getting the right answer.
Jun 11 '07 #6
FishVal
2,653 Expert 2GB
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_Name is text
2) combo Medication_Name.BoundColumn is a column corresponding to Meds.Medical_Name

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

Good luck.
Jun 11 '07 #7
pukhton
75
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_Name is text
2) combo Medication_Name.BoundColumn is a column corresponding to Meds.Medical_Name

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_Name" 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 Expert 2GB
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_Name" 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="SELECT Meds.Concentration, 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
I can suggest you the following another way.

1) change in design view the following Medication_Name combo properties
.RowSource="SELECT Meds.Concentration, 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
FishVal
2,653 Expert 2GB
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.
Sure.
By the way it will be interesting for me to see myself what a is happening in your db.
Jun 11 '07 #11
FishVal
2,653 Expert 2GB
Sure.
By the way it will be interesting for me to see myself what a is happening in your db.
Sorry the option to receive e-mails was disabled. Now you can sent. If you will enable this option in your profile I will send you my sample.
Jun 12 '07 #12
pukhton
75
Sorry the option to receive e-mails was disabled. Now you can sent. If you will enable this option in your profile I will send you my sample.
Thanks, and sorry for taking long. I have enabled my email, so please send me yours. I am sending you mine. Take a look.

You will see on the main form u have a Medication combo box and right under that you have a concentration text box. I want my user to pick medication from the drop down menu, when they do that, the text box for concentration should get populated by it self from the table "Meds". Each medication has a standrad concentration. It works fine on the form, but the concentration text box is not saving into the MainTable. Please take a look, and help me out.
Jun 12 '07 #13
pukhton
75
Thanks, and sorry for taking long. I have enabled my email, so please send me yours. I am sending you mine. Take a look.

You will see on the main form u have a Medication combo box and right under that you have a concentration text box. I want my user to pick medication from the drop down menu, when they do that, the text box for concentration should get populated by it self from the table "Meds". Each medication has a standrad concentration. It works fine on the form, but the concentration text box is not saving into the MainTable. Please take a look, and help me out.
sorry it doesnt let me attach the file, syas invalid file. I thinks its mdb file thats why..
please send me your file at pukhton77@hotmail.com
and i will send you mine back.
Jun 12 '07 #14
pukhton
75
I need help please.

What i am trying to achieve is to save value from Meds Table and save it in Main Table.

Meds tabel has two colums, Medication_Name and Concentration.
Each medication has standrad concentration.

I have a combo box for Medications and text box for Concentration in my Form. When User picks medication, the concentration text box gets populated from the Meds colum, but that value is not saving in the Main Table.
please help me out...
Jun 18 '07 #15

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

Similar topics

5
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...
2
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...
0
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...
11
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...
2
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
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...
1
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...
7
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
0
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,...
0
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
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,...

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.