Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 26 of 26

Thread: How to autopopulate a text field based on a check boxes being ticked msacc 2007?

  1. #21
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    447
    Location
    Quote Originally Posted by wedd
    I've adapted the checkboxes to my database. Although the checboxes are working fine...at the moment the prices aren't automatically appearing in the text box. Any reasons why this may be happening? Could it also be something to do with the security settings on my database?
    Please show us your code.

  2. #22
    VBAX Mentor
    Joined
    Aug 2010
    Posts
    457
    Location
    No errors are appearing. Its just when I click on the various checkboxes thedifferent prices of the deposits son't appear. A similar thing occured when I first opened the database you sent me...however I changed the trust settings and it worked well.

  3. #23
    VBAX Mentor
    Joined
    Aug 2010
    Posts
    457
    Location
    Here is my code:

    Private Sub fraOrganisations_AfterUpdate()
    Dim curDeposit As Currency
    Dim strError As String
    Select Case Me.fraOrganisations
    Case 1 ' Maitland Park Sports Centre
    curDeposit = 100#
    Case 2 ' Queens Crescent Community Centre
    curDeposit = 200#
    Case 3 ' Fleet Community Centre
    curDeposit = 100#
    Case 4 ' Equipment
    curDeposit = 100#
    Case Else ' oops
    strError = "unexpected value for fraOrganisations: " & _
    Me.fraOrganisations
    End Select
    If Len(strError) > 0 Then
    MsgBox strError
    Else
    Me.txtDeposit = curDeposit
    End If
    End Sub

  4. #24
    VBAX Mentor
    Joined
    Aug 2010
    Posts
    457
    Location
    I've included equipment as a new option. Thanks for your help

  5. #25
    VBAX Mentor
    Joined
    Aug 2010
    Posts
    457
    Location
    I am using access 2007. I'm not sure if that could be causing the issue...

  6. #26
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    447
    Location
    Quote Originally Posted by wedd
    No errors are appearing. Its just when I click on the various checkboxes thedifferent prices of the deposits son't appear. A similar thing occured when I first opened the database you sent me...however I changed the trust settings and it worked well.
    OK, I will assume your database is stored in a trusted location. Let me know if we need to discuss that point further.

    I don't see anything wrong with the AfterUpdate code. And it looks to me like you added equipment properly.

    Add a MsgBox line to your code as I indicated below. The reason for this is to determine whether fraOrganisations_AfterUpdate is evaluated at all after you select a different check box on the form.

    Since you're running the database from a trusted location, the only other reason I can suggest for why fraOrganisations_AfterUpdate wouldn't run is if the option group frame is not named fraOrganisations.

    Anyway, the first step is for you to tell us whether or not you see the MsgBox.

    [vba]Private Sub fraOrganisations_AfterUpdate()
    Dim curDeposit As Currency
    Dim strError As String

    MsgBox "fraOrganisations_AfterUpdate active"

    Select Case Me.fraOrganisations
    Case 1 ' Maitland Park Sports Centre
    curDeposit = 100#
    Case 2 ' Queens Crescent Community Centre
    curDeposit = 200#
    Case 3 ' Fleet Community Centre
    curDeposit = 100#
    Case 4 ' Equipment
    curDeposit = 100#
    Case Else ' oops
    strError = "unexpected value for fraOrganisations: " & _
    Me.fraOrganisations
    End Select
    If Len(strError) > 0 Then
    MsgBox strError
    Else
    Me.txtDeposit = curDeposit
    End If
    End Sub[/vba]

Posting Permissions

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