Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    233

    Unanswered: cant reference a property of a control unless the control has focus

    I am trying a simple calc for my form and table, the code is below but im getting the error that i cant get vals from the txtboxes unless they have focus:

    Private Sub Balance_AfterUpdate()
    updateAvailableCredit
    End Sub
    Sub updateAvailableCredit()
    Dim bal As Double
    Dim limit As Double
    Dim availCredit As Double

    bal = IIf(IsNull(Me.Balance.Text), 0, CDbl(Me.Balance.Text))
    limit = IIf(IsNull(Me.CreditLimit.Text), 0, CDbl(Me.CreditLimit.Text))
    availCredit = limit - bal

    Me.AvailableCredit = CStr(availCredit)

  2. #2
    Join Date
    Mar 2007
    Posts
    277
    AFAIK, only the .Text property insists the control have the focus. Use the .Value property.
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  3. #3
    Join Date
    Oct 2003
    Posts
    233
    cool, hmm i made the changes, but what i want is to update the availableCredit field in the table that is the source of the form, the value isnt displaying in the control or updating the table

    Sub updateAvailableCredit()
    Dim bal As Double
    Dim limit As Double
    Dim availCredit As Double

    bal = IIf(IsNull(Me.Balance.Value), 0, CDbl(Me.Balance.Value))
    limit = IIf(IsNull(Me.CreditLimit.Value), 0, CDbl(Me.CreditLimit.Value))
    availCredit = IIf(limit <> 0, limit - bal, bal)

    Me.AvailableCredit.Value = CStr(availCredit)

    End Sub

  4. #4
    Join Date
    Mar 2007
    Posts
    277
    Have you single stepped the code to see what is happening? A SubRoutine needs to be called:
    Private Sub Balance_AfterUpdate()
    Call updateAvailableCredit
    End Sub
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •