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

Update an Unbound Textbox using a ChkBox event 1

Status
Not open for further replies.

plcman

Programmer
Feb 17, 2001
92
0
0
GB
Hi

I am using Access 2003, I am trying to perform a calculation and put the result in an unbound text box, If my chkbox(LotPrice) is true I want the calc to be price * qty and if false just price.

I have put the code below in the afterupdate event but I get an error message.

"You must save the field before you execute the gotocontrol action, the gotocontrol method, or the setfocus method"



Text4.SetFocus

If LotPrice = -1 Then
Text4.Text = Price * Qty
Else
Text4.Text = Price
End If

I have the same code in the forms afterupdate event and it works fine.


Any help really appreciated.

Alan
 
You don't tell us what Afterupdate event your code is in.

You should not use the Text property. Just use the Value (or no) property without setting the focus.
Code:
If Me.LotPrice = -1 Then
   Me.txtBetterNameHere = Me.Price * Me.Qty
  Else
   Me.txtBetterNameHere = Me.Price
End If


Duane
Hook'D on Access
MS Access MVP
 
Hi

Thanks for that, my code is in the afterupdate of the chkbox.

Your solution sorted the problem, though I dont really understand why. The error messages I got while trying to sort this out don't seem to help.

Anyway Duane Many thanks for your help

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top