Results 1 to 2 of 2
  1. #1
    Kotoca is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    3

    Set value of bound combobox to NULL


    Hi

    I'd appreciate help on the following issue - can't find the solution myself.

    Goal of my Database: Recording bank transaction (money transfers from one account to another)

    Details: On the form on which I record these transaction I have two combo-boxes: 1)Account Debited and 2)Account Credited.
    Both combo-boxes have the same source, which is an Active-Account-Query.

    I have the following code to avoid Account Credited and Account Debited to be the same:
    Private Sub ctlCreditAccountNumber_BeforeUpdate(Cancel As Integer)
    If Me.ctlCreditAccountNumber = Me.ctlDebitAccountNumber Then
    MsgBox "The Credited account must be " _
    & vbCrLf & " DIFFERENT" _
    & vbCrLf & "than the Debited account!", _
    vbInformation, "Inconsistency"
    Cancel = True
    End If

    End Sub

    This code works fine, but the problem I have is, that when the focus returns to the combobox ctlCreditAccountNumber, the account number I've entered just before (and which is wrong) is still there. I would like the combobox to be clear of any text, after the message box disappears.

    I have tried putting the rowsource to "", I have tried = Null, and Undo but nothing works. From what I gather, the reason for that is that the combobox is a bound field. That is something I can't change though.

    Any solutions?
    Any help would be greatly appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Setting the RowSource would not be relevant.

    According to this article, the Undo method should work. http://msdn.microsoft.com/en-us/libr...ffice.12).aspx
    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: 1
    Last Post: 02-23-2012, 02:27 PM
  2. Bound form with bound combobox
    By Jerry8989 in forum Access
    Replies: 2
    Last Post: 12-05-2011, 01:50 PM
  3. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 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