rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

Treat MS-Access Forms as such #1171

Open retailcoder opened 8 years ago

retailcoder commented 8 years ago

MS-Access forms are document modules (as opposed to Excel forms, which are UserForm modules) and currently get picked up as such:

MS-Access Forms

When the host application is MS-Access and a document module's name starts with Form_, we need to inspect its designer to pick up the controls, like we do for UserForms.

(ref. #827)

ThunderFrame commented 8 years ago

Reports have a Report_ prefix.

ThunderFrame commented 8 years ago

IIRC, the Form and Report components vary by the version of Access (or perhaps it's the Access file format), so the behavior of Forms and Reports might vary according to the host, or according to the host that was used to create them.

retailcoder commented 8 years ago

Ok, ..but we'll be looking for a Controls collection. Isn't that member guaranteed to be present and implemented by the interface?

ThunderFrame commented 8 years ago

IIRC the accessibility of Access document-type components depends upon whether the document is open in design view, and perhaps, to a lesser extent, if the code module is open.

That is, I'm not sure that the controls collection is available, unless the form is open is design view. Opening a form/report into design view takes time...

ThunderFrame commented 8 years ago

Excel keeps worksheet ActiveX controls in the Worksheet Shapes collection. Word keeps ActiveX controls in the Document.Fields collection.

ThunderFrame commented 8 years ago

I don't think Access 2013 Forms or Reports have VBA Designers, or not as far as the VBIDE is aware.

Access can have standard UserForms, which do have Designers, but Access Forms and Reports do not return a DesignerID, and HasOpenDesigner is always false, regardless of whether the Form/Report is open in Access' design view.

The Properties collection of the vbComponent is unavailable if the Form/Report is closed, but is available if the Form/Report is in Design mode, which means you can retrieve the Controls collection from the properties, but only when the form is open in the Access UI.

The above didn't seem to vary by Access File Format version, but it might vary according to the version of Access.

retailcoder commented 8 years ago

I don't have MS-Access so I can't test this live - I'd rather move it to 2.1 than put something together that just blows up when it runs in an actual MS-Access environment.