473,385 Members | 1,872 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,385 software developers and data experts.

Editing data from database in textbox which are taken from subform

In my form I have a subform, which displays A, B, C. Then information C is displayed in textbox. User should have a possibility to modify this data in order to modify data in database.

I am able to display information C in text box based on this subform. However it is uneditable, although property of enabled is yes and locked is no.

It seems to me, that it is impossible to edit data because it is taken not directly from database but from sub form, so I make special query which takes data directly from database however I lose an event which is based on selecting proper record from subform (there is only onEnter and onExit events)

Is it possible to make such things?

Thank you for any advices!

[ModEdit>>z{Merged post #2 by OP as follows}]

"I am able to display information C in text box based on this subform. However it is uneditable, although property of enabled is yes and locked is no."

I received a message "Control can't be edited; it's bound to the expression".
Jul 11 '13 #1

✓ answered by zmbd

IMHO, You are making things too complex.

Rabbit hit the nail on the head (has the correct answer) as to why you can not edit the information directly in the textbox-C on the mainform.

You have a few options; however, none of them as easy as letting the user modify the data in the subform which is bound to the query. Otherwise you are stuck with a ton of vba.

With your current set-up (and I'm guessing)
Take txt-C and unbind it, remove the control source.
In your subform, in the on_current event, you will copy the current code to the txt-c,
In the after update event of txt-c you will need to check to see if the value in the subform matches the value in txt-c - if not then save the value in txt-c to the current record in subform.
Your Txt-A will need some simular code to work to alter what is in C. Clear as mud (Z-Z)... ?

11 3190
zmbd
5,501 Expert Mod 4TB
t seems to me, that it is impossible to edit data because it is taken not directly from database but from sub form,
It is more likely that your recordset for the subform is not from an editable source, at least for that field.

Please read thru: > Before Posting (VBA or SQL) Code

Then post your SQL for the subform.
Jul 11 '13 #2
Rabbit
12,516 Expert Mod 8TB
I suspect they are using a textbox bound to an expression related to the subform and attempting to edit that bound control rather than the source data.
Jul 11 '13 #3
Thank You for a replay.

So, data in subfrom are editable.

SQL Code (no VBA, written in Record Source) for subPurpose:
Expand|Select|Wrap|Line Numbers
  1. SELECT qryPurpose.[ID Job Position]
  2.    ,qryPurpose.Discipline, qryPurpose.Position
  3.    ,qryPurpose.Purpose 
  4. FROM qryPurpose; 
or without query it can be written:
Expand|Select|Wrap|Line Numbers
  1. SELECT [Job Positions].[ID Job Position]
  2.    ,Positions.Position, Disciplines.Discipline
  3.    ,[Job Positions].Purpose
  4. FROM Positions
  5.    INNER JOIN (Disciplines 
  6.       INNER JOIN [Job Positions]
  7.          ON Disciplines.[ID Discipline] 
  8.             = [Job Positions].[ID Discipline])
  9.       ON Positions.[ID Position] 
  10.          = [Job Positions].[ID Position];
and txtPurpose which is a text box:
Expand|Select|Wrap|Line Numbers
  1. Control Source: 
  2.    =[subPurpose]![Purpose]
Jul 11 '13 #4
Rabbit,

How can I get data from database through text box, depending on selected position from subform and then have a possibility to modify them?
Jul 11 '13 #5
zmbd
5,501 Expert Mod 4TB
I'm with Rabbit on this,
Where exactly is this control "C" located in your forms.
Jul 11 '13 #6
There is a simple form with text box in Detail section and subform in footer section.
Jul 11 '13 #7
zmbd
5,501 Expert Mod 4TB
Please be specific:

The text box showing the information "C" is located where, main form, sub form 1, or some other form or location.
Jul 11 '13 #8
Thank You for patience.
The text box showing the information "C" is located in main form in Detail Section.
The sub form is located in the same main form in Footer Section. It takes data from query, but taking data directly from table makes no difference.

All I want is to modify information C based on selected A. My idea was to make a subform, where user can select A and because of length of information and aesthetic point of way display info C not in the same subform as A but in seperate Text box. Everything is going well apart the fact that I can't modify info C in text box.
Jul 11 '13 #9
It is possible to make another sub form with info C depending on sub form with info A, which can editable. So it will be probably the best idea, I just create a nice looking another sub form.
Jul 11 '13 #10
zmbd
5,501 Expert Mod 4TB
IMHO, You are making things too complex.

Rabbit hit the nail on the head (has the correct answer) as to why you can not edit the information directly in the textbox-C on the mainform.

You have a few options; however, none of them as easy as letting the user modify the data in the subform which is bound to the query. Otherwise you are stuck with a ton of vba.

With your current set-up (and I'm guessing)
Take txt-C and unbind it, remove the control source.
In your subform, in the on_current event, you will copy the current code to the txt-c,
In the after update event of txt-c you will need to check to see if the value in the subform matches the value in txt-c - if not then save the value in txt-c to the current record in subform.
Your Txt-A will need some simular code to work to alter what is in C. Clear as mud (Z-Z)... ?
Jul 12 '13 #11
Yep, everything is working now as I wanted!

I also used suggestions from this topic:
http://bytes.com/topic/access/answer...vent-main-form

I wrote about this problem on a few forum, but You gave me right answer.

Thank You for support and solution!
Jul 12 '13 #12

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

Similar topics

2
by: Jake_adl | last post by:
Is there any way to create a Microsoft.Practices.EnterpriseLibrary.Data.Database object without reading from a configuration file? I am writing a utility that manages databases in SQL Server....
2
by: Vijaya | last post by:
Can we bind data to textbox in a headertemplate in a template column of a datagrid? If so please give some code snippets. Thank you
3
by: luanhoxung | last post by:
Hi all !! i have met trouble with referring textbox of subform in VBA i know i can do as: forms!mainform.subform.textbox but i want do it in shorter path. any suggestion about using variable ?...
3
by: panwala_bhavesh | last post by:
I have a subform in continuous form style that I use to populate 3 fields (textboxes) on my main form with a double-click of the key-field textbox of the sub: Private Sub...
4
by: khyati30 | last post by:
hi, i am working on asp i am facing problem in asp , combox i want to retrive data in textbox , from combobox . in combobox , when i select particular user , i want to fetch that regarding...
4
by: jain19801 | last post by:
I Have Created Connection Object, Dataadapter And Fill The Dataset But Afterwards I Am Unable To Display The Data In Textbox Or Label
3
by: durga2005 | last post by:
hi im using webgrid control and i have used template columns to display the data from the database while editing the data in webgrid, im storing the the new values in two strings for using...
0
by: jaredciagar | last post by:
Hi Guys, can You help me please in my project.... I'm using VB Script,ASP.Net,MS SQL Server 2005 I want to save data in gridview control from data in textbox control.... How can I Do It?...
7
reginaldmerritt
by: reginaldmerritt | last post by:
I have a few forms which i have designed to be subforms to a mainform that has no fields or record source. The forms have an unbound textbox and combo box, which i use to seach the data on these...
2
arun3232
by: arun3232 | last post by:
how can i display data to textbox using sql server in asp.net with c#..
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.