Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2008
    Location
    All over, Now in Missouri
    Posts
    73

    Unanswered: Getting VBA to Pass info to Form Field

    Trying to get some VBA in Access report to look at three fields and determine if the student has a passing grade and then pass a string to an unboound field

    Here is what I have so far!

    Private Sub txtgs_BeforeUpdate(Cancel As Integer)

    If Me.GSWrittenTest1 > 69 Then
    Me.txtgs = "1st time go"
    ElseIf Me.GSWrittenTest2 > 69 Then
    Me.txtgs = "2nd time go"
    ElseIf Me.GSWrittenTest3 > 69 Then
    Me.txtgs = "3rd Time go"
    ElseIf Me.GSWrittenTest3 < 70 Then
    Me.txtgs = "3rd Time no go"
    End If

    End Sub

  2. #2
    Join Date
    May 2008
    Location
    Raleigh, NC
    Posts
    151

    More info

    Quote Originally Posted by PJHAction
    Trying to get some VBA in Access report to ....
    I'm not sure where this code is...on a form? In a report? The code looks OK if its on a form, except for maybe where you have it. You are trying to set the value of Me.txtgs in the before update event of the field itself. Maybe you should have it in the on current event of the form instead?

    Good luck, Stu
    --If its free, take it for what its worth!

  3. #3
    Join Date
    Feb 2004
    Posts
    214

    If it is on a form

    should it be After_Update instead of Before?
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  4. #4
    Join Date
    Apr 2008
    Location
    All over, Now in Missouri
    Posts
    73
    This code is part of the Report, should it be in Load_Form?

  5. #5
    Join Date
    Feb 2004
    Posts
    214

    ...

    I believe it should be On_Format in the Details section.
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  6. #6
    Join Date
    Apr 2008
    Location
    All over, Now in Missouri
    Posts
    73
    I moved it to the Detail_Format in my report and it worked just fine.

    Thanks

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Quote Originally Posted by PJHAction
    This code is part of the Report, should it be in Load_Form?
    You do realise that forms are not the same as reports... right ?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  8. #8
    Join Date
    Apr 2008
    Location
    All over, Now in Missouri
    Posts
    73
    You bet, I just need to summarize some data for a report. I needed to use vba in the background to get a result for my report. I expanded my code and it works great. It is OK to use VBA in a report right?

  9. #9
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    It is OK to use VBA in a report right?
    Absolutely!
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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