Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I pass a recordset between forms?

Status
Not open for further replies.

tashayar

Programmer
Apr 22, 2003
2
US
I am working in VB6. I build my recordset in a separate search form. I return to my main form and the first record is displayed. When I try to access the next record, the recordset is empty. I am setting the main global recordset equal to the search form created recordset to try and pass it back to the main form. (Set rst1 = rst2) This is moderately urgent. I would appreciate any help you could provide. tashayar
 
If you add a module to your project and declare your recordset there as public it'll be available throught out the project.
 
use property let and property let event to pass recordset between form.
 
Thanks for your suggestion. The recordset I was trying to pass to was already Public and in a Module. I tried making the search form recordset Public and put it in a module, but I get an "object not set" error on the main recordset after returning to the main form and attempting to movenext. The recordset is filled just before I hide the search form and return to the main form. After the return, it is gone. tashayar
 
'Module
Public adoRS As New ADODB.Recordset


'Search Form
adoRS.open strSQL, strConnection

'Main Form
adoRS.MoveNext '<- Should Work


'When finished with rs
adoRS.Close

 
If it is REALLY public and REALLY in a module, the look if the recordset is being closed and Set to Nothing somewhere.
Otherwise it should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top