Results 1 to 4 of 4
  1. #1
    nhdee is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2013
    Posts
    22

    Combo Box If then Else

    I have a combobox on my form and the following vba code:

    Private Sub GCR_Click()

    'Puts the Gift Certificate Balance in the GC payment field when select the GC# [Named GCR] to redeem

    If Me![GCR].Column(2) > AmtDue Then
    Me!GC = [AmtDue]

    Else

    If Me![GCR].Column(2) < AmtDue Then
    Me!GC = [GCR].Column(2)

    End If
    End Sub

    The combo box displays three columns from a query: GC#[GCR]; GC Original Amt [Amt] and Balance. Bound by Column = 1


    What I want to happen is: If the Amount Due is greater than the current balance of the Gift Certificate I want the Gift Certificate Payment field to be the balance of the gift certificate. Right now it is always making it equal to the Amount Due??? So if the Amount due is $10.00 but the gift certificate balance is only $5.00 I only want $5.00 to go in the GC (payment) field and the user will have to collect more money (no problem with that). What am I doing wrong?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Part of the problem is saving calculated data. Usually a bad idea. Ideally balances would be calculated by aggregating transaction records.

    Have you step debugged? Follow the code as it executes, see where it deviates from expected behavior. See link at bottom of my post for debugging guidelines.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    nhdee is offline Novice
    Windows 8 Access 2013
    Join Date
    Oct 2013
    Posts
    22
    The balance is calculated in the query. The combo box shows the query results. I want to prevent a user from "over-selling" a gift-certificate so I want to force the GC balance to go in as payment. Do you have any other recommendations?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    You keep track of GC balances? Seems to me gift certificates I've used didn't work that way. Had to use it up in single purchase. It would be offered as form of payment like cash except maybe no change returned if purchase was less than the GC amount. That's the simplest approach. Customer has to use it up or lose it.

    Magnetic strip gift cards is a different issue.

    Did you try the step debugging?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 07-03-2013, 10:38 AM
  2. Replies: 3
    Last Post: 12-11-2012, 09:12 AM
  3. Replies: 1
    Last Post: 10-30-2012, 10:29 AM
  4. Replies: 2
    Last Post: 08-16-2012, 10:02 PM
  5. Replies: 4
    Last Post: 08-16-2011, 05:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums