Results 1 to 3 of 3
  1. #1
    Join Date
    May 2019
    Posts
    65

    Showing changed value ain a control

    I am in a combobox (Combo242, which is a ContactID#) and I enter a new full name which is not on the list. My notinlist event runs and if I answer yes a pop-up form allows me to add the new contact. After the contact is saved, I am automatically returned to the control and want to fill it with the new value. I set the new value to TempVars!contactID and then try to requery, I get the error message "You cannot requery as the control has not been saved.
    I can't figure out how to show the new Contact.

    Code:
    Private Sub Combo242_NotInList(NewData As String, Response As Integer)
    
    
        NewContact = StrConv(NewData, vbProperCase)
        If MsgBox(NewContact & " Is not in the Contact list." & Chr(10) & _
        "Do you want to add it to the Contacts?", _
              vbYesNo + vbQuestion) = vbYes Then
    
    
                DoCmd.OpenForm "frmContactsLight", acNormal 'Opens a pop-up form to add the contact data
                If TempVars!JustCameFromContactsLight = 1 Then ' This is a flag from the pop-up form
                
                Me.Combo242 = TempVars!ContactID
                Me.Combo242.Requery ' Here is get the error "You cannot requery because the control has not been saved"
                TempVars!ContactID = "" ' This resets the TempVars
                End If
        TempVars!JustCameFromContactsLight = 0 ' This resets the flag
        
        End If
        
        Response = acDataErrContinue



    Any help is appreciated



    Jeff

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Open the form in dialog mode to suspend code execution on calling form until dialog form closes.

    DoCmd.OpenForm "frmContactsLight", acNormal, , , , acDialog

    Then maybe do the requery before populating box with new value.
    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
    Join Date
    May 2019
    Posts
    65
    THAT WORKED!!!
    I Changed the code to:
    Code:
    Private Sub Combo242_NotInList(NewData As String, Response As Integer)
    
    
       
        NewContact = StrConv(NewData, vbProperCase)
        If MsgBox(NewContact & " Is not in the Contact list." & Chr(10) & _
        "Do you want to add it to the Contacts?", _
              vbYesNo + vbQuestion) = vbYes Then
    
    
                DoCmd.OpenForm "frmContactsLight", acNormal, , , , acDialog
                
                If TempVars!JustCameFromContactsLight = 1 Then
                
                Me.Combo242 = TempVars!ContactID
                Me.Combo242.Requery
                      
                TempVars!ContactID = ""
                End If
        TempVars!JustCameFromContactsLight = 0
               
        
        End If
        
        Response = acDataErrContinue
        
    
    
    
    
    
    
    End Sub
    Thank you June7 you are always a good source of info.

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

Similar Threads

  1. Replies: 8
    Last Post: 10-14-2019, 02:09 PM
  2. Replies: 6
    Last Post: 05-09-2015, 11:28 AM
  3. Replies: 12
    Last Post: 10-01-2014, 08:17 PM
  4. ActiveX Control Calendar not showing
    By wlkr.jk in forum Programming
    Replies: 3
    Last Post: 07-22-2014, 07:23 AM
  5. Replies: 1
    Last Post: 08-13-2013, 10:06 AM

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