Ask a Question related to Microsoft Access, Design and Development.
-
June Macleod #1
Re: Selecting Multiple Values in a List/Combo Box
The following should work:
On your close button add the following line before the close command
getWellList
docmd.close
then add the following code to your form module:
Note: You will need to replace lstWells with the name of your listbox on
your form and [BasedON] with the name of the text box you wish to store the
results in.
Public Sub getWellList()
Dim ctlsource As Control
Dim intCurrentRow As Integer
Dim frm As Form
Dim strarray$
Set frm = Me
Set ctlsource = frm.Controls("lstWells")
strarray = ""
strTextArray = ""
For intCurrentRow = 0 To ctlsource.ListCount - 1
If ctlsource.Selected(intCurrentRow) Then
strarray = strarray & ctlsource.Column(0, intCurrentRow) & ","
End If
Next intCurrentRow
Set frm = Nothing
Set ctlsource = Nothing
[BasedON] = strarray
End Sub
if you wish to have the stored values selected when you open the form then
add the following:
on the form load event add
FillInWellList
then to the form module add the following :
Again, replace lstWell and BasedOn with the values from your own form
Public Sub FillInWellList()
On Error GoTo err_fillinwellList
Dim ctlsource As Control
Dim intCurrentRow As Integer
Dim frm As Form
Dim strarray$
If [BasedON] > "" And Not IsNull([BasedON]) Then
Set frm = Me
Set ctlsource = frm.Controls("lstWells")
strarray = [BasedON]
Do While InStr(1, strarray, ",") > 0
x = InStr(1, strarray, ",")
thenum = Left(strarray, (x - 1))
For intCurrentRow = 0 To ctlsource.ListCount - 1
If ctlsource.Column(0, intCurrentRow) = thenum Then
ctlsource.Selected(intCurrentRow) = True
End If
Next intCurrentRow
strarray = Mid$(strarray, x + 1)
Loop
End If
Set frm = Nothing
Set ctlsource = Nothing
exit_fillinwellList:
Exit Sub
err_fillinwellList:
' thiserr = record_errors(Err, Left(Err.Description, 255), "Project Header
Information - fillinwellList", gErrorName)
msgbox err.description
Resume exit_fillinwellList
End Sub
One more thing, if you have your form module set to Option Explicit you may
have to define a few more of the variable names.
Hope this helps
June Macleod
"William W" <wellsbro5@yahoo.com> wrote in message
news:012501c34fa4$39234730$a301280a@phx.gbl...> I would like to be able to select AND store the selections
> in a text field seperated by commas.
>
> Is their any way to do this? When I turn on multiselect in
> a lists properties and select multiple values, it is not
> reflected in my table data...
>
> Thanks
> William W
June Macleod Guest
-
submit multiple values from a list box PHP
Can any one tell me how to submit multiple values from a list box? I believe it has something to do with Arrays or Loops but i'm not sure. this is... -
multiple select list default values (asp/vb)
(asp/vb) Hi all, I have a multiple select list on an insert record form. I can make multiple selections and insert them into the database... -
Multiple Values in a list box
Hi everybody. If anyone can tell me how can I choose multiple values in a list box (by using ctrl or shift buttons) and store them in a table.... -
Limiting List in a Combo Box, while showing values not in it.
I currently have a table with three values in it. "Open", "Closed", and "Queued for Closing." I want the users to only have the ability to... -
Selecting records based on multiple values
I'm trying to select records which have a FIELD_VALUE = x, y, or z. I've tried several things and I can't seem to make it work correctly. Here is...



Reply With Quote

