Assign Form's Record

G

Guest

(I use WinXP, AccessXP, JET SP 8, ADO 2.8)

Hello.

I create a form with a subform inside. Subform has a linked table as
RecordSource. I assign it in Form Design View. When *main* form is opened, I
create a module-level DAO recordset and assign it to subform's Recordset (Set
subform.Recordset = MyDAO.Recordset). It worked fine until one day, GPF
happened and I can not solve that error. I have tried to decompile, compile
and compact. Error still occur. So, I decide to remove linked table in
subform's RecordSource and leave it blank in Form Design View. This time,
program work ok. (Note : I assigned linked table to able to select
ControlSource in subform)

From your experience, What did I do in the first time , Is it suitable ? or
that causes the GPF ?

Any suggestion is very appreciate
 
A

Allen Browne

Several possible issues.

1. In Access 2002/2003, there is a bug that can crash Access if the field
named in the LinkChildFields fo your subform control is an object of type
AccessField. You can work around the problem by placing a text box on the
subform for this field, because then it is an object of type Textbox. If you
don't have a text box for this field, try adding one. Set its Visible
property to No if you wish.

2. I've also found that assigning the Recordset of the form like that can be
dicey. Access can crash if a field just disappears (e.g. you left it out of
your SQL string), or if the field changes data type (applies to calculated
fields). It may have just been these issues or #1 above, but last time I
tested this approach I found it too unstable and decided not to use it any
more. IME, it is much simpler and safer to dynamically build a string and
assign it to the RecordSource property of the form.

3. There are also logical problems with this approach. If the main form is
bound also, Access changes the Recordset of the subform whenever a different
record is loaded into the subform - not useful.

4. Access can also decide to reassign whatever it things should be in the
LinkMasterFields/LinkChildFields, so you may have to reassign these after
you change the RecordSource.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top