Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting textbox value after updating a different textbox 2

Status
Not open for further replies.

Gfunk13

Programmer
Feb 28, 2004
17
US
After updating a textbox, I am attempting to run this code to update a seperate textbox:

Dim dbs As Database, rst As DAO.Recordset
Set dbs = CurrentDb
Set mtd = Me.MTDhrs

Set rst = dbs.OpenRecordset("SELECT Sum(Ahrs)+Sum(Bhrs)+
Sum(Chrs) AS Expr2 FROM Production
WHERE (((DatePart('m',[proddate]))=Month(Now())));")

mtd.Value = rst("Expr2")

----------
I get Run-time error '2448' (You can't assign a value to this object).

 
which line is highlighted when in debug mode ?
Why not simply this ?
Me!MTDhrs = Nz(DSum(Nz(Ahrs,0)+Nz(Bhrs,0)+Nz(Chrs,0), "Production", "Month(proddate)=Month(Now())"), 0)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV, I commented out all of my previous code and tried:

Me!MTDhrs = Nz(DSum(Nz(Ahrs,0)+Nz(Bhrs,0)+Nz(Chrs,0), "Production", "Month(proddate)=Month(Now())"), 0)

but I got the same error.

---
To answer the question about the highlighted in debug:

mtd.Value = rst("Expr2")
 
Are you sure that MTDhrs is updatable ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
It is enabled and not locked. I do not have a control source assigned, but I can type a value into the field.
 
Why not create a Function to run your code and then place the function in the Default Value property of the text box mtd. Remove MTD.Value= whatever. I called the Function GetSum

=GetSum()



Life's a journey enjoy the ride...

jazzz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top