Link Form/Subform where no records exist.

  • Thread starter Thread starter Charles P. \(Pat\) Upshaw
  • Start date Start date
C

Charles P. \(Pat\) Upshaw

I have a form/subform which worked fine in Access97. Now, in Access 2003,
whenever I open the form (in Form View) when no records exist it crashes.

I can open the form in design view, then switch to form view just fine, and
it opens just fine after I've added a record.

This is very annoying.

Thanks,
Charles P. (Pat) Upshaw
 
Charles, this could be a number of things, such as:
a) a Name AutoCorrect problem;
b) a compilation error;
c) a bug with the AccessObject type in A2002 and 2003.

Try this sequence:

1. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

2. Compact the database to get rid of this junk:
Tools | Database Utilities | Compact
That takes care of (a).

3. Close Access. Make a backup copy of the file. Decompile the database by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

4. Open Access, and compact again.
That takes care of (b).

5. Open the main form in design view.
Right-click the subform control, and choose Properties.
On the Data tab, write down what is in LinkMasterFields and LinkChildFields.
Then delete the entries for both these properites.
Save, and close the main form.

6. Locate the subform itself on the Forms tab of the Database window, and
open in it design view. Make sure there is a text box for the field(s) that
were named in LinkChildFields. Set its Visible property to No if you wish,
but the control with that Name and Control Source must be on the form. Save
and close the subform.

7. Open the main form again, and re-enter the LinkMasterFields and
LinkChildFields. That should take care of (c), since the LinkChildFields now
refers to an object of type TextBox which does not have the bug of the
AccessObject (the object type when the LinkChildFields refers to a field
that is not also a control.)

8. Open a code window.
Choose References from the Tools menu.
Uncheck any references you do not need.
For a list of the ones you typically need in your version of Access, see:
http://allenbrowne.com/ser-38.html

9. Still in the code window, choose Compile from the Debug menu.
Fix any errors, and repeat until it compiles okay.

At this point, you should have a database where the name-autocorrect errors
are gone, the indexes are repaired, inconsistencies between the text- and
compiled-versions of the code are fixed, the AccessObject error is bypassed,
reference ambiguities are resolved, and the code syntax is compilable.

If it is still a problem, the next step would be to get Access to rebuild
the database for you. Follow the steps for the first symptom in this
article:
Recovering from Corruption
at:
http://allenbrowne.com/ser-47.html
 
Back
Top