'Check Box Drop Down' Multi Value Field.

caferacer

Registered User.
Local time
Today, 14:40
Joined
Oct 11, 2012
Messages
96
Hi All,

Trying to use some code to 'Select All' from a 'Check Box Drop Down' Multi Value Field . The table field size is long integer.

When trying to ‘Select All’ the code returns a RTE 3163 “This field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data”.

Private Sub cmdSelectAll_Click()
Dim SelVals, i
ReDim SelVals(0 To lkupAssignedTo.ListCount - 1)
For i = 0 To lkupAssignedTo.ListCount - 1
SelVals(i) = lkupAssignedTo.Column(1, i)
Next i
lkupAssignedTo.Value = SelVals
End Sub

Not my code, but just something I have found and trying to adapt.
Tried changing the field sizes but no luck. Maybe somethign to do with declaring variables perhaps??

Any ideas

Thanks

Mark.
 

Attachments

seems you took this code from VB, not VBA

try this:
Code:
Private Sub cmdSelectAll_Click()
Dim SelVals
dim i as long
ReDim SelVals(me.lkupAssignedTo.ListCount - 1)
For i = 0 To me.lkupAssignedTo.ListCount - 1
SelVals(i) = me.lkupAssignedTo.Column(1, i)
Next i
me.lkupAssignedTo.Value = SelVals
End Sub
 
You can do it on this way:
Code:
Private Sub cmdSelectAll_Click()
  Dim i
  Me.lkupAssignedTo.SetFocus
  Me.lkupAssignedTo.Dropdown
  For i = 0 To lkupAssignedTo.ListCount - 1
    Me.lkupAssignedTo.Selected(i) = True
  Next i
  Me.lkupAssignedTo.Requery
End Sub
 
Hi,

Thanks for the help. With a bit of tweaking got the code below to work.

Regards

Mark

Private Sub cmdSelectAll_Click()
Dim SelVals(), i
ReDim SelVals(0 To lkupAssignedTo.ListCount - 1)
For i = 0 To lkupAssignedTo.ListCount - 1
SelVals(i) = CLng(lkupAssignedTo.Column(0, i))
Next i
lkupAssignedTo.Value = SelVals
End Sub
 

Users who are viewing this thread

Back
Top Bottom