What are the exact names of the 6 "Boxes"?
What are the exact names of the 6 "Boxes"?
You would have to post all relevent code for analysis. How on earth do you deselect output? We could keep going in circles like this forever. I analyse best with the actual objects and their code. If you can't provide project by suggested means, maybe someone with better insight will contribute.
RuralGuy: see post #9
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.
@June7: Sorry, I had missed that.
His naming sequence needs to be bumped as the 1st one does not seem to end with a number.
Yeah, post #10 addresses that.
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.
June7,
Regarding the deselection of items, the following code is used...
Private Sub lstSelected_DblClick(cancel As Integer)
On Error GoTo Err_cmdDeselect_Click
Dim db As Database
Dim rs As DAO.Recordset
Dim varItem As Variant
Dim lngItem As Long
Dim strItem As String
Dim strsql As String
Dim rsMan As DAO.Recordset
Set db = CurrentDb
strsql = "SELECT * FROM tblOutputFormatT WHERE IDTask LIKE '" & Me.TaskNum & "'"
Set rs = db.OpenRecordset(strsql, dbOpenDynaset)
With Me!lstSelected
For Each varItem In .ItemsSelected
' lngItem = .Column(0, varItem)
strItem = .Column(0, varItem)
With rs
.MoveFirst
.FindFirst "[IDOutput] = '" & strItem & "'"
If Not .NoMatch Then
.delete
End If
End With
Next varItem
End With
rs.Close
Set rs = Nothing
Set db = Nothing
' With Me!lstSelected
' For lngItem = 0 To .ListCount - 1
' .Selected(lngItem) = False
' Next lngItem
' End With
Me.lstSelected.Requery
Me.lstAvailable.Requery
Me.lstSelected = vbNullString
Exit_cmdDeselect_Click:
Exit Sub
Err_cmdDeselect_Click:
MsgBox Err.Description
Resume Exit_cmdDeselect_Click
End Sub
Ok so i've managed to get the Qty box to show, however the first Qty box doesn't show until the second choice has been made. (See pic), secondly when you move on to the next record the same Qty box still shows. Thirdly when you exit the form and go back into it the Qty boxes have dissappeared completely. (see Pic)
Lastly if i select more than 6 items i get an error message "Cannot find the field (Numoutput7) refferred to in your expression.
HELLP!!!
Well, how many items are users allowed to select? As I understand, you need a quantity box for each selected item. Your setup has 6 quantity boxes. Should users be limited to that (will need code to control)? If not, this is looking like an unworkable design.
Also beginning to think the easier option is, once users make selection of sizes, to click a button that opens a form with the selected size records and input quantities into this form instead of trying to control the visibility/nonvisibility of controls in interactions with this form.
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.
I think that a limit of 6 selections will be fine, but how do you code for that, have sent PM with details ref your PM.
June7,
I have found another sample DB that has the same kind of list box that my form has on it, maybe it would be easier to use this than mine.
Yes, made life much easier. Your project was proving to be an aggravating although educational exercise. It would have taken me a lot more time to get it to work, if at all.
See if this is what you want. The demo you provided uses command buttons to trigger the update of listboxes. I retained that structure. If you want to use event of listboxes, will need to rework code. It may be a little more complicated.
I will remove the file after you respond or in a few days. EDIT: Purpose served, file removed. Suggested code was a procedure to set the visibility textboxes that could be called from any other procedure of the form.Also, to make sure number of selections is limited:Code:Private Sub SetQtyBoxes() Dim i As Integer For i = 1 To 6 Me.Controls("tbxQty" & i).Visible = False Next For i = 1 To Me.lstSelected.ListCount Me.Controls("tbxQty" & i).Visible = True Next End Sub
If Me.lstAvailable.ItemsSelected.Count + Me.lstSelected.ListCount > 6 Then
MsgBox "Only six items may be selected. Remove the excess."
Else
'code to update lstSelected
End If
Last edited by June7; 07-30-2011 at 02:25 PM.
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.
June7,
Fantastic!!!!, this is exactly what i want, you say that to put this into the event of the listbox would take a little more code, could you not just place the code into the doubleclick event and get the same effect, if not this will be superb.
Well, try it and see what happens. Either way, user has to click something. The button may be more intuitive because it is visually apparent what it is for. What clue do users have to use double click?
I just realised these listboxes are set as Extended. User must hold shift key to selecte multiple items and there is no clue for the user this is required. Setting of Simple does not require shift key.
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.
Ok, so that works on the doubleclick event of the Listbox (Great) 1 question if i may, if there are no items in the listbox selected, if you click within i get a runtime error 5, Invalid procedure call or argument, when i go to debug mode it shows the line
strwhere = Left(strwhere, Len(strwhere) - 4)
Any ??
Make sure some items are selected:
If Me.lstSelected.ItemsSelected.Count > 0 Then
'code to remove selected items
End If
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.
That didn't work, placed in the code with items selected, once all items were removed from list if i clicked again then same error.!!