Setting a form property before opeing it.

  • Thread starter Thread starter Malc
  • Start date Start date
M

Malc

I am trying to set a forms recordsource property before I open it.

e.g Forms!["customer tariff"].RecordSource = sql

However I am getting runtime error 2450 (Can't find the form)

I am sure this has worked before, any ideas?

Malc.
 
The Forms collection is a collection of *open* forms, if the form isn't
open, it's not in that collection. You can get at forms without opening them
via other collections (DAO Containers and Documents or
CurrentProject.AllForms) but you can't manipulate the Recordsource property
via those collections. In short, you can't change the recordsource property
before opening the form. You could, if you wish, open the form hidden, and
set the property before displaying it.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
You can set the Form's RecordSource in the Form_Open Event. This doesn't
make any difference from the user's point of view whether you assign the
RecordSource "before" you open the Form or during the opening process since
the Form is invisible at this stage.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top