Runtime error #2448 Cannot assign value to this control

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
 
G

Guest

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 ()
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top