Edit control on main form from subform procedure

DevinM21

Registered User.
Local time
Yesterday, 20:40
Joined
Dec 4, 2009
Messages
13
Hello : )
I've tried a ton of different ways to go about this and i'm completly stumped.

I have a main form with subform. On the Subform's beforeupdate event i want to change somehting on the mainform. so my code looks liek this:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Forms![new1]![Date Modified] = Now()
End Sub

i've tried me.parent![Date Modified]
i've tried creating a function in a module that runs this code and calling the function from the subform's beforupdate procedure.

idk what to do please help.:confused:

the Error message i get: "The Expression before update you entered as the event property setting produced the following error: object or class does not support the set of events."
 
You may be trying to fire this on the main form subform control. You need to be inside the actual sub form form, if that makes sense. First I would advise just trying to get the subform before update event to do something simple like display a msgbox before you look at other potential issues...
 
If you are simply interested in the current date use Date() in preference to Now(). As Now() also includes the current time and will complicate the business of comparing dates.
 
Oh yes and avoid using spaces and other special characters in object and control names, as this complicates the process of writing code. Stick with Alpha-Numerics and underscore ("_")
 
ok yea i tried a simple Msgbox "Hey"
and it gave the same error message.
 
You can't set a control's value (on the main form) from the subform's Before Update event. The update for the subform has to occur yet and it can't dirty the main form while the subform is still dirty. So, try putting your code in the subform's AFTER update event.
 
I've tried the afterupdate event also. the 'msbBox "Hey"' still gives the same error.
 
actually i can't get any events from the subform to work. What could be the reason for that?

now i can get the control on the main form for the subform to work, it has two events to choose from. on open vent and on exit event. those I can display a MsgBox with. but on the form's event's nothing works.
 
Can you get them to fire if you open the subform by itself?
 
I cannot get them to fire if i open the subform by itself, and i'm sorry I can't post the database. oh but i need help so bad. i'm looking into detecting a subform event from main form procedure. idk how to do that yet though.
 
Thank you guys for your time and answers btw. I really appreciate the help. : )
 
Okay, it is just that much harder to be able to help and it is looking like we may be reaching the end of what we can do without actually seeing the db because in cases like these it is usually a simple matter of you have certain information which is important to the solution, but you don't know that it is important and we have so many possible things to look for that we overlook the possible little thing that is causing the issue. I've seen that many times here. And normally it takes about 30 seconds to 3 minutes to figure it out and get it resolved once we actually have the database in hand.
 
My best other guess is that you've put another bit of code / logic some where that mucking the thing up. I'd try rebuilding the subform from scratch...
 
the code from within a subform is

parent!fieldname = whatever

and this should work without problems.

so if this isnt working, its probably because you have two forms in a single container, or two forms operating independently (ie not a true from/related subform), or the fieldname is wrong etc.
 

Users who are viewing this thread

Back
Top Bottom