Event Procedure Bug?

  • Thread starter Thread starter derekwittman
  • Start date Start date
D

derekwittman

Good afternoon,
I'm working on a small application that contains a combo box to select
integers ranging from 1 - 8. I have txtboxes for each of these
options. Should the user select 3, then 3 txtboxes will be visible,
while the remaining 5 will go visible = no. Each of these textboxes is
waiting for the user to enter a percentage from 1 - 100% such that the
sum total of them all is 100% (another text box). My form is unbound
(faster on the front end). I want to create an event procedure for a
Lost Focus event for textbox1 that updates my "remaining percent"
textbox with 1 - textbox1's value.

My problem is that when I go to the OnLostFocus property and select
either [Event Procedure] or ... it does NOT creat my SUB and End Sub
statements... Does anyone know why this is? VBA opens up to the last
place I was editing - not where it should go.

My "Submit" button will contain code to verify that the sum of the
percents is 100%.

Here is the code for textbox1:

Private Sub txtPC1_LostFocus()
Dim varPC1 As Variant
varPC1 = Forms!frmShortForm.txtPC1
Forms!frmShortForm.txtRemaining = 1 - varPC1
Me.Requery
End Sub

Thank you in advance!
Derek
 
Derek,

I am not able to explain the behaviour you are seeing. But I would
comment that in my opinion the After Update event would be preferable.
Also, I can't see that the Requery is necessary? Try it like this...

Private Sub txtPC1_AfterUpdate()
Me.txtRemaining = 1 - Me.txtPC1
End Sub
 
Back
Top