Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Me.lstCFT_Summary.Recordset.RecordCount
    CRAP! My fingers were disconnected from my brain because I tested (and it worked) then typed something else.

  2. #17
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038
    Thsnk you, Micron! Appreciate the help.

  3. #18
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I'm not sure how I cross reference the two forms
    Code:
    If Me.lstCFT_Summary.Recordset.RecordCount + Me.lstOPT_Summary.Recordset.RecordCount + Me.lstWS_Summary.Recordset.RecordCount > 0 Then
       Forms!frmStaffMembers.ControlNameHere.Visible = False
    End If
    That form has to be open - not necessarily visible.

  4. #19
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038
    Micron, June:

    Sorry for the delayed response... got sidetracked with another project activity. Anyhow, I implemented the proposed code into a sample database (see attached) and I now end up with some error messages **after** I navigated across a few records.

    I'm testing some code and use message boxes to indicate the count of items shown in three listboxes. Once those counts were w/o issues, I later on will remove the message boxes and replace them with some other actions.

    At this time, however, I end up with an error after navigating through a few records. If you were to following the process outlined below, an error is thrown after a few clicks.

    Sequence of process that results in an error:

    1. Open form "F00_Billets

    2a. Select combo "Go to" (under the dark blue banner in the top left of the form) and pick, e.g., record ID starting with "0007777".
    2b. A message box appears showing a count of 2, 0, 2 for CFT, OPT, and WS, respectively. Click Ok!
    2c. Now review the 3 listboxes (CFT, OPT, and WS). The count displayed in the message box (i.e., 2, 0, 2) matches the count of # of items displayed in the three listboxes. Great!

    3a. Now, select combo "Go to" and pick, e.g., record ID starting with "0004444".
    3b. A message box appears showing a count of 2, 1, 1 for CFT, OPT, and WS, respectively. Click Ok!
    3c. Now review the 3 listboxes (CFT, OPT, and WS). The count displayed in the message box (i.e., 2, 1, 1) matches the count of # of items displayed in the three listboxes. Great!

    4a. Finally, select combo "Go to" and pick, e.g., record ID starting with "0001111".
    4b. A dialogue box appears indicating "Invalid Operation".
    4c. Also, if I then select a previously selected record (e.g., 0007777), I get the same error.

    My question: What is missing/erroneous in the AfterEvent of the GoTo combo, given that I get the correct listbox counts (via message box) but ultimately results in consistent errors?

    EEH
    Attached Files Attached Files

  5. #20
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    In cboGoToBillets_afterupdate you were summing one thing but displaying another. Change the first line as below.
    Code:
        If Me.lstCFT_Summary.ListCount + Me.lstOPT_Summary.ListCount + Me.lstWS_Summary.ListCount > 0 Then
    
    
            MsgBox "Billet is assigned to the following WQSB:" & vbCrLf & "CFT: " & [lstCFT_Summary].
    [ListCount] & _
                 vbCrLf & "OPT: " & [lstOPT_Summary].
    [ListCount] & _
                   vbCrLf & "WS: " & [lstWS_Summary].
    [ListCount], vbInformation, "Information"
    
    
        Else
            
            MsgBox "Billet is NOT assigned to any WQSB!", vbInformation, "Information"
        
        End If
    Last edited by davegri; 02-28-2020 at 05:43 PM. Reason: I give up on formatting

  6. #21
    skydivetom is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    1,038
    Davigri... perfect! Thank you so very much for your prompt & excellent help!

  7. #22
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I have never used Screen.ActiveForm. Not sure why using GotFocus event.

    It is not necessary to set focus on a listbox or combobox to requery it.

    I observe the error starts on 3rd go around, doesn't matter what values are selected nor what order. I added a Debug.Print.

    Debug.Print Me.lstCFT_Summary.Recordset.RecordCount + Me.lstOPT_Summary.Recordset.RecordCount + Me.lstWS_Summary.Recordset.RecordCount

    The second go around always outputs 13. Since RecordCount is not dependable, use ListCount which is returning correct values.

    And now I see Dave's response.
    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.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 08-18-2018, 10:23 AM
  2. Make last record in Form's RecordSource the current record
    By GraeagleBill in forum Programming
    Replies: 6
    Last Post: 06-27-2018, 10:43 AM
  3. Listbox in form is current upon form open
    By LonghronJ in forum Modules
    Replies: 3
    Last Post: 03-18-2018, 10:01 AM
  4. Replies: 1
    Last Post: 05-18-2015, 01:27 AM
  5. Replies: 3
    Last Post: 02-06-2015, 01:18 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