G
Guest
Hi, Problem with code in form after selection is made.
code:
Private Sub cmdSome_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!lstCName.ItemsSelected.Count = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me!lstCName.ItemsSelected
' Grab the CompanyID column for each selected item
strWhere = strWhere & Me!lstCName.Column(0, varItem) & ","
Next varItem
' Throw away the extra comma on the "IN" string
strWhere = Left$(strWhere, Len(strWhere) - 1)
' Open the companies form filtered on the selected companies
strWhere = "[ShipperID] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="frmCustShipper", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub
had gotten code from MS Access 2003 inside/out.
code works find if ShipperID is autonumber field, even for mutliple
selection. My ID fields are text, when next form opens all fields are
blank,like new record.
I did find out that if I change the strWhere statement to:
'strWhere = "[ShipperID]= '" & strWhere & "' "
this works, but can only select one record at time to be in next form when
it opens.
The secord form is a edit form, would like to select all records which need
editing before going to next form.
How do you code ( IN ) for mutliselect for ID fields which are text not
Interger?
code:
Private Sub cmdSome_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!lstCName.ItemsSelected.Count = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me!lstCName.ItemsSelected
' Grab the CompanyID column for each selected item
strWhere = strWhere & Me!lstCName.Column(0, varItem) & ","
Next varItem
' Throw away the extra comma on the "IN" string
strWhere = Left$(strWhere, Len(strWhere) - 1)
' Open the companies form filtered on the selected companies
strWhere = "[ShipperID] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="frmCustShipper", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub
had gotten code from MS Access 2003 inside/out.
code works find if ShipperID is autonumber field, even for mutliple
selection. My ID fields are text, when next form opens all fields are
blank,like new record.
I did find out that if I change the strWhere statement to:
'strWhere = "[ShipperID]= '" & strWhere & "' "
this works, but can only select one record at time to be in next form when
it opens.
The secord form is a edit form, would like to select all records which need
editing before going to next form.
How do you code ( IN ) for mutliselect for ID fields which are text not
Interger?