Editing SubForm Data From Main Form! (1 Viewer)

vdanelia

Registered User.
Local time
Today, 10:03
Joined
Jan 29, 2011
Messages
215
Hello Need your help.
I want to edit, add, delete data of sub-form field (it Is a Memo Field) from main table...

Please Help!
 

randompherret

New member
Local time
Today, 12:03
Joined
Nov 3, 2011
Messages
8
add the memo to your main form query (or make it unbound from the main form and just bound to the memo query) and then on an after update event use requery on the subform control.
 

vdanelia

Registered User.
Local time
Today, 10:03
Joined
Jan 29, 2011
Messages
215
My Main form is based on Table not query, I created unbound-text box, i created a memo query, how to set that query to unbound text box as control source
 

vdanelia

Registered User.
Local time
Today, 10:03
Joined
Jan 29, 2011
Messages
215
Hello VbaInet

I have a sub-form on the main form it is OK, but I needed that on my main form to be displayed one field from a sub-form "PcInfo" and that i could it edit (delete, add or edit values there: there are only PC component names)
Then I created unbound text box, created a query, set it as control source, but not works :(
I think that I'm doing something wrong
 

vbaInet

AWF VIP
Local time
Today, 18:03
Joined
Jan 22, 2010
Messages
26,374
Why do you have to put it on your main form?

Is your subform in Datasheet view?
 

vdanelia

Registered User.
Local time
Today, 10:03
Joined
Jan 29, 2011
Messages
215
Mu sub form is "Continuous Form"
I'm adding it because it is very comfortable to edit pcinfo from main table, in the future i can show or hide it by a command button.
 

vbaInet

AWF VIP
Local time
Today, 18:03
Joined
Jan 22, 2010
Messages
26,374
Why don't you put it in the Header or Footer section of your subform?
 

vdanelia

Registered User.
Local time
Today, 10:03
Joined
Jan 29, 2011
Messages
215
Because of My form design......
I did it (=[SForm].[Form]![PcInfo]) Displaying everything as needed, but can't edit the field
 

vbaInet

AWF VIP
Local time
Today, 18:03
Joined
Jan 22, 2010
Messages
26,374
If you put it in the Header section of the SUBFORM, you just need to set the Control Source as [pcInfo]
 

vdanelia

Registered User.
Local time
Today, 10:03
Joined
Jan 29, 2011
Messages
215
On the sub-form it works perfectly, but I needed it on my Main form..
Is it difficult to solve that problem, I tried many variants,but none of them worked
 

vbaInet

AWF VIP
Local time
Today, 18:03
Joined
Jan 22, 2010
Messages
26,374
Is it difficult to solve that problem, I tried many variants,but none of them worked
I didn't say it's difficult ;) I'm just trying to make you think of other ways of working.

In the AfterUpdate event of the textbox that is in the subform and in the On Current event of the subform, do this:
Code:
Me.Parent.MainTextboxName = Me.PcInfo
where MainTextboxName is the name of the textbox in the main form.

In the After Update event of the textbox that is in the main form, do this:
Code:
Me.SubformControlName!PcInfo = Me.MainTextboxName
where SubformControlName is as the name implies.
 

vdanelia

Registered User.
Local time
Today, 10:03
Joined
Jan 29, 2011
Messages
215
Greatest Thanks vbaInet
Works perfectly :)
You're Super
 

vdanelia

Registered User.
Local time
Today, 10:03
Joined
Jan 29, 2011
Messages
215
Hello vbaInet

I noticed something strange:
Everything is working perfectly, but when I'm opening the sub-form it says: Run-Time Error '2452' Expression you Entered has invalid reference to that parent property
 

vbaInet

AWF VIP
Local time
Today, 18:03
Joined
Jan 22, 2010
Messages
26,374
That's because your subform loads before the main form and Parent (in the Current event) refers to the main form but at this time it hasn't loaded and thus can't be found. So what you need to do is this:

1. In the property sheet of the subform, remove the word [Event Procedure]. Don't touch the code behind it, leave it as it is.
2. Save and close the subform.
3. In the Current event of the main form put this:
Code:
Me.SubformControlName.OnCurrent = "[Event Procedure]"
Done!

There's another way, but I prefer this one.
 

vdanelia

Registered User.
Local time
Today, 10:03
Joined
Jan 29, 2011
Messages
215
Hello vbaInet
I did it and now opening the sub-form without any error
Thanks a lot
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom