Results 1 to 4 of 4
  1. #1
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    31

    Need to refresh form to display updated data

    I have a form that is opened through the "After Update" Event of a combo box. The combo box presents an integer to a DoCmd.OpenForm method so that the form opens showing information for a desired record. The following code snippet shows how the form is opened:

    Function SearchByNameLO_Up_Top()
    Dim BorrowerQuickSearchBtn As String
    Dim BorrowerQuickSearchBtn1 As String
    On Error GoTo SearchByNameLO_Up_Top_Err
    ' Name the Borrower Quick Search Button
    BorrowerQuickSearchBtn = "Forms!" & strSwitchboard & "!Combo114"
    BorrowerQuickSearchBtn1 = "[Forms]![" & strSwitchboard & "]![combo114]"
    DoCmd.SetWarnings False

    If (IsNull(BorrowerQuickSearchBtn) = True) Then
    End
    End If


    If (IsNull(DLookup("InUseBy", "qryInUseStatusCP")) = True Or DLookup("clientid", "qryInUseStatus") <> BorrowerQuickSearchBtn) Then
    DoCmd.OpenForm "LO View", acNormal, "", "[client id]=" & BorrowerQuickSearchBtn1, , acNormal
    End If

    If (DLookup("clientid", "qryInUseStatus") = BorrowerQuickSearchBtn) Then
    fncFileInUseMsgbox
    End If

    If (DLookup("clientid", "qryInUseStatus") = BorrowerQuickSearchBtn) Then
    DoCmd.OpenForm "LO View", acNormal, "", "[client id]=" & BorrowerQuickSearchBtn1, acReadOnly, acNormal
    End If


    In this example, Combo114 is the combo box
    This code works perfectly.



    However when I make a copy of that combo box and rename it and create another bit of code:

    Function PullUpAnotherClientInLOView()
    Dim SelectedUser As Integer

    On Error GoTo PullUpAnotherClientInLOView_Err

    DoCmd.SetWarnings False


    SelectedUser = Forms![Lo View]!cboLoViewClientQuickSearch
    ' If there is nothing to search for then exit


    If (IsNull(SelectedUser) = True) Then
    End


    End If

    DoCmd.Close acForm, "LO View"


    ' If no one else is looking at this client other than the current user then open "LO View" for this client
    If (IsNull(DLookup("InUseBy", "qryInUseStatusCP")) = True Or DLookup("clientid", "qryInUseStatus") <> SelectedUser) Then

    DoCmd.OpenForm "LO View", acNormal, "", "[Client ID] = SelectedUser", , acNormal
    End If

    When the DoCmd.OpenForm method is run in this instance, I am prompted for the value of "SelectedUser", even though it is obviously assigned in the code. Once I enter it, the rest of the code runs fine. When I "Add Watch", the variable "SelectedUser" displays its assigned value just fine.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Don't enclose variables in quote marks, concatenate.

    DoCmd.OpenForm "LO View", acNormal, "", "[Client ID] = " & SelectedUser, , acNormal
    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
    pledbetter is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Martinsville, IN
    Posts
    31

    That was it!

    Quote Originally Posted by June7 View Post
    Don't enclose variables in quote marks, concatenate.

    DoCmd.OpenForm "LO View", acNormal, "", "[Client ID] = " & SelectedUser, , acNormal
    I can't tell you the various combinations I tried; I never would have guessed that. Thanks!

    OK, next question: How do I mark this as solved or completed? Is there a way to give you credit for this solution?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Credit not really important but click the star icon at lower left of post window.

    Mark solved with the Thread Tools dropdown at top of thread.
    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: 12
    Last Post: 12-20-2013, 12:36 PM
  2. Replies: 1
    Last Post: 09-17-2013, 11:30 AM
  3. Refresh data on menu form
    By bibbyd01 in forum Forms
    Replies: 3
    Last Post: 04-19-2012, 08:48 AM
  4. Replies: 8
    Last Post: 01-20-2012, 05:07 PM
  5. Replies: 8
    Last Post: 06-22-2011, 10:51 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