Hi!
I am trying thru a while loop in a vb program behind the access report. I have a form where I enter txtSubject.
I want to search for all the subjects in the database that have in them the txtSubject and then print them in a report.
I am having a problem sending the string to the open report here is my code:
Dim dbs as Database
Dim rsSelect as Recordset
Dim Mypos as Interger
Dim Mypos1 as Interger
Dim nm as Variant
Dim I as Interger
Dim sqlstring(2000) as String
set dbs=CurrentDb
("Set rsSelect = dbs.OpenRecordset("Tbl_Bakashot")
With rsSelect
(nm = Array(2000))
Do while Not.Eof
(For I = LBound(nm to Ubound(nm))
If not IsNUll (!SubjectH) then
(MyPos = Instr(1,!SubjectH,Me.txtSubject)
If Mypos<>0 then
sqlstring(nm(I)) = !CodeBakasha
Endif
Endif
If not IsNUll (!SubjectH) then
(MyPos1 = Instr(1,!SubjectE,Me.txtSubject)
If Mypos1<>0 then
sqlstring(nm(I)) = !CodeBakasha
Endif
Endif
MoveNext
Next I
Loop
EndWith
Docmd.OpenReport "Rep_SubjectFromBakashot",acPreview,"CodeBakasha= " & (sqlstring(nm(I))
EndSub
Please let me know what I am doing wrong and maybe there is a better way to do it.
Help please.
Thanks,

ST
I am trying thru a while loop in a vb program behind the access report. I have a form where I enter txtSubject.
I want to search for all the subjects in the database that have in them the txtSubject and then print them in a report.
I am having a problem sending the string to the open report here is my code:
Dim dbs as Database
Dim rsSelect as Recordset
Dim Mypos as Interger
Dim Mypos1 as Interger
Dim nm as Variant
Dim I as Interger
Dim sqlstring(2000) as String
set dbs=CurrentDb
("Set rsSelect = dbs.OpenRecordset("Tbl_Bakashot")
With rsSelect
(nm = Array(2000))
Do while Not.Eof
(For I = LBound(nm to Ubound(nm))
If not IsNUll (!SubjectH) then
(MyPos = Instr(1,!SubjectH,Me.txtSubject)
If Mypos<>0 then
sqlstring(nm(I)) = !CodeBakasha
Endif
Endif
If not IsNUll (!SubjectH) then
(MyPos1 = Instr(1,!SubjectE,Me.txtSubject)
If Mypos1<>0 then
sqlstring(nm(I)) = !CodeBakasha
Endif
Endif
MoveNext
Next I
Loop
EndWith
Docmd.OpenReport "Rep_SubjectFromBakashot",acPreview,"CodeBakasha= " & (sqlstring(nm(I))
EndSub
Please let me know what I am doing wrong and maybe there is a better way to do it.
Help please.
Thanks,