Error 2448 when trying to assign a value to control on parent form (1 Viewer)

MatMac

Access Developer
Local time
Today, 13:40
Joined
Nov 6, 2003
Messages
140
Hi - I'm getting the dreaded error 2448 "You can't assign a value to this object". (Have reviewed the forums but can't find an applicable solution.)

This occurrs when I try and asign a value to a control in the parent form of the current subform:

Private Sub SetForecastWarning()
If DSum("useForecast", "Phase", "projID=[Forms]![Project]![projID]") = -1 Then
Me.Parent![ForecastGen] = -1
End If
End Sub

I've also tried [Forms]![Project]![ForecastGen] = -1

Any ideas why I can't assign a value to the field "ForecastGen" in this manner?

Note:

In another similar thread, Bob Larson writes: You can't set a value for a bound text box until the LOAD event. The Open event is too early as the recordset has not yet been loaded.

This sub is run from the "Form_Current" event, and occurs when I try and open the parent form. Could this be the problem? If so, can anyone suggest a workaround?

Many thanks.
 
Last edited:

MStef

Registered User.
Local time
Today, 13:40
Joined
Oct 28, 2004
Messages
2,251
Look at the field ForecastGen properties.
What is in the CONTROL SOURCE ???
 

MatMac

Access Developer
Local time
Today, 13:40
Joined
Nov 6, 2003
Messages
140
MStef - the field ForecastGen is bound to a Yes/No field "Gen" within my "Projects" table - the control source of my parent form.
 

MStef

Registered User.
Local time
Today, 13:40
Joined
Oct 28, 2004
Messages
2,251
I think teh error is in above line "If DSum..........
 

MatMac

Access Developer
Local time
Today, 13:40
Joined
Nov 6, 2003
Messages
140
No - there's nothing wrong with that. Other code - not shown above - within my IF statement to hide/show fields executes correctly when I comment out the line in red.
 

MStef

Registered User.
Local time
Today, 13:40
Joined
Oct 28, 2004
Messages
2,251
Try in above line write the code,
If (DSum("[useForecast]","Phase","[ProjID]=" & [Forms]![Project]![ProjID])) = -1 Then
 

MatMac

Access Developer
Local time
Today, 13:40
Joined
Nov 6, 2003
Messages
140
Okay - have done - but it makes no difference. I'm sure my If statement is correct.
 

MStef

Registered User.
Local time
Today, 13:40
Joined
Oct 28, 2004
Messages
2,251
Send a short example of your DB. Access 2000 or 2002.
 

MatMac

Access Developer
Local time
Today, 13:40
Joined
Nov 6, 2003
Messages
140
Thanks MStef - do appreciate yopur help - but its a pretty complex database, and it would be difficult to trim down. For IPR reasons I'm not able to send the whole thing out unfortunately.
 

MatMac

Access Developer
Local time
Today, 13:40
Joined
Nov 6, 2003
Messages
140
Its something to do with the point at which the sub is run. Just tested and the code works fine when EXCEPT when OIPENING the form.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 13:40
Joined
Sep 12, 2006
Messages
15,755
if its just a startup problem (ie when its first run), then try putting it in the current event of the subform, rather than the open event.

if its erroring you could also just put

on error resume next before it, to suppress the error
 

MatMac

Access Developer
Local time
Today, 13:40
Joined
Nov 6, 2003
Messages
140
Thanks Gemma-the-husky. I have resorted to suppressing the error - but I hate not knowing why it is happening!

It actually is in the CUrrent event, not the Open event as per my original post :)
 

Users who are viewing this thread

Top Bottom