Runtime error #2448 Cannot assign value to this control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an unbound control named INCLUSION in a report named SCHOOL_FTEs that
I want to populate with a value from a field named CountOfINCLUSION from a
query named INCLUSION_TOTALS, which is not the Record Source. I have a macro
set up to run the code listed below when the report opens. Yet I'm getting a
the Runtime error #2448 Cannot assign a value to this object when the
function tries to run. It stops on the last line of this function.

Function Get_Amount ()

Dim dbs As Database
Dim rst As Recordset

Set dbs = Current Db
Set rst = dbs.OpenRecordset("SELECT * FROM INCLUSION_TOTALS")
[Reports]![SCHOOL_FTEs]![INCLUSION] = rst!CountOfINCLUSION

End Function

What will need to be done to get the needed value over into the report?
Thanks in advance,
RC
 
You don't need the function, you can write in the text box control source

= DLookUp("CountOfINCLUSION","INCLUSION_TOTALS")

For future need, you can set the value of the field to the function

Function Get_Amount ()

Dim dbs As Database
Dim rst As Recordset

Set dbs = Current Db
Set rst = dbs.OpenRecordset("SELECT * FROM INCLUSION_TOTALS")
Get_Amount = rst!CountOfINCLUSION

End Function

And then in the control source of the text box write
= Get_Amount ()
 
Thanks Ofer, this worked great!

Ofer Cohen said:
You don't need the function, you can write in the text box control source

= DLookUp("CountOfINCLUSION","INCLUSION_TOTALS")

For future need, you can set the value of the field to the function

Function Get_Amount ()

Dim dbs As Database
Dim rst As Recordset

Set dbs = Current Db
Set rst = dbs.OpenRecordset("SELECT * FROM INCLUSION_TOTALS")
Get_Amount = rst!CountOfINCLUSION

End Function

And then in the control source of the text box write
= Get_Amount ()

--
Good Luck
BS"D


RC said:
I have an unbound control named INCLUSION in a report named SCHOOL_FTEs that
I want to populate with a value from a field named CountOfINCLUSION from a
query named INCLUSION_TOTALS, which is not the Record Source. I have a macro
set up to run the code listed below when the report opens. Yet I'm getting a
the Runtime error #2448 Cannot assign a value to this object when the
function tries to run. It stops on the last line of this function.

Function Get_Amount ()

Dim dbs As Database
Dim rst As Recordset

Set dbs = Current Db
Set rst = dbs.OpenRecordset("SELECT * FROM INCLUSION_TOTALS")
[Reports]![SCHOOL_FTEs]![INCLUSION] = rst!CountOfINCLUSION

End Function

What will need to be done to get the needed value over into the report?
Thanks in advance,
RC
 
Back
Top