CRAP! My fingers were disconnected from my brain because I tested (and it worked) then typed something else.Me.lstCFT_Summary.Recordset.RecordCount
CRAP! My fingers were disconnected from my brain because I tested (and it worked) then typed something else.Me.lstCFT_Summary.Recordset.RecordCount
Thsnk you, Micron! Appreciate the help.
I'm not sure how I cross reference the two formsThat form has to be open - not necessarily visible.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
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
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
Davigri... perfect! Thank you so very much for your prompt & excellent help!
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.