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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: Can't assign a value to this object...(textbox)...

Status
Not open for further replies.

Ovatvvon

Programmer
Feb 1, 2001
1,514
0
0
US
Hello,
I am making a form to keep track of a bunch of subscribers to a group. In the form I have created in Access 2000, I have it so you can input how many people are comming for tickets in one text box (Numsub). In the next box, you input how much it costs per ticket (AmtSub). Then I wanted it so you can click on a "calc" button and it will automatically insert the value of Numsub * AmtSub into Total. However it keeps telling me I can't assign a value to this object.

Does anyone know what I'm doing wrong?
Here is the code:

Private Sub Calculating_Click()
Dim Numb, Amount
Numb = Val(Numsub)
If Numb = "" Then
Numb = 0
End If
Amount = Val(AmtSub)
If Numb = "" Then
Numb = 0
End If
Total = " $" & Numb * Amount

End Sub


Thanks for your help in advance!!!
-Ovatvvon

 
Try this:

[tt]
Private Sub Calculating_Click()
Total = Format(Val(nz(NumSub)) * Val(nz(AmtSub)),"Currency")
End Sub
[/tt]

Suggestion 1
If you are storing the Amt and the Price at the time of the order, it is not always necessary to store a Total field because the total can be calculated whenever it is needed in a query. The total is unneccessary data because it can be derived from the other data in the record.

Suggestion 2
If you do choose to use this code, move it to the AfterUpdate event and put a copy behind the control with AmtSub and NumSub. By doing this the Total field will be calculated whenever a change to either field is made an the user won't have to click a button.

HTH Joe Miller
joe.miller@flotech.net
 
It still doesn't work.
It give's me the error:

Run-time error '-2147352567 (80020009)':

You can't assign a value to this object.


Would it be easier if you saw a sample of the database if I emailed it to you, or you can download it from my web site. If so, I can email you and give you the url where to download it. Don't want to post it here.

Else,
have any other ideas why it doesn't work?

Thanks for you time!
-Ovatvvon :-Q
 
Just sent you a sample from my hotmail account...should be there shortly. 1.2MB. Office 2000.

Thanks for your help!!!

:-D
 
Ovatvvon- I have a very similar problem. If its quick, can you brief me on what you learned?
Thanks-
Andy
 
Is your text box bound? If it is, you can't assign a value to it. You can only assign a value to an unbound text box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top