Hi Sakis!
Give a try to this code for the "Copy Button":
(I have commented the unnecessary/wrong lines)
Code:
Private Sub copyF_Click()
Dim rst As Object
Dim strTemp As String
'strTemp = vbNullString
'If Nz(Form_STUDENTS.chkAll, False) Then
'Set rst = Form_STUDENTS.RecordsetClone 'Wrong object reference!
Set rst = Me!STUDENTS.Form.RecordsetClone
With rst
If Not .BOF Then .MoveFirst
While Not .EOF
If !CheckS Then
strTemp = strTemp & .Fields("SelPh") & ","
End If
.MoveNext
Wend
End With
'End If
Me.txtCOPY = Null
If Len(strTemp) > 0 Then
Me.txtCOPY = Left(strTemp, Len(strTemp) - 1)
End If
If Not rst Is Nothing Then Set rst = Nothing
End Sub
Also I suggest this simpler condition for the WHERE clause of the recordsource of the form STUDENTS:
Code:
WHERE (((STUDENTS.Ενεργός)=[Forms]![frmCOPY]![STUDENTS]![ChkFilter] Or (STUDENTS.Ενεργός)=-1))
I hope it helps and welcome to accessforums!
John
Edit:
But there is a better practice: You can move the whole functionality in the STUDENTS form as a Build-In, Read-Only property, making with this way much simpler the outer procedures.
Add this Property Get method in the code module of the STUDENTS form:
Code:
Property Get Phones() As Variant
Dim varTemp As Variant
varTemp = Null
With Me.RecordsetClone
If Not .BOF Then .MoveFirst
While Not .EOF
If !CheckS Then
varTemp = varTemp & ("," + .Fields("SelPh"))
End If
.MoveNext
Wend
End With
Phones = Mid(varTemp, 2)
End Property
Then, you have only one line of code to add in click event of the copy button (and any other procedure):
Code:
Private Sub copyF_Click()
Me.txtCOPY = Me!STUDENTS.Form.Phones
End Sub