How do I set RecordSource from another form?

  • Thread starter Thread starter M Skabialka
  • Start date Start date
M

M Skabialka

This should be from Access 101, but I can't figure out how to set the
recordsource on frmDocs from another form which is opening it, based on a
user selection on that form in Access 2000.



DoCmd.OpenForm "frmDocs"



The following all give me errors trying to set the Record Source from
another form (where Me!lstTables = "tblDocument")



Forms!frmDocs.RecordSource = Me!lstTables

2580 The record source 'tblDocument' specified on this form or report does
not exist. (Yes it does, it is a table)



Forms("frmDocs").RecordSource = Me!lstTables

2101 The setting you entered isn't valid for this property.



Forms("frmDocs").RecordSource = "SELECT * FROM " & Me!lstTables

2101 The setting you entered isn't valid for this property.



Forms!frmDocs.RecordSource = "SELECT * FROM tblDocument"

2101 The setting you entered isn't valid for this property.



Set frm = Forms!frmDocs

frm.RecordSource = Me!lstTables

2101 The setting you entered isn't valid for this property.



What am I doing wrong?

Thanks,

Mich
 
I would try opening it using the OpenArgs property with it being the name of
the recordsource. Then in the Load event of frmDocs, use the OpenArgs to set
the recordsource.
 
I haven't used this before....

DoCmd.OpenForm "frmDocs", , , , , , Me!lstTables
Forms!frmDocs.RecordSource = Forms!frmDocs.OpenArgs

But it works.
Thanks,
Mich
 
Back
Top