Solved Filter Update Causes Crash (1 Viewer)

Drand

Registered User.
Local time
Tomorrow, 03:30
Joined
Jun 8, 2019
Messages
51
Hi

I have a form that tracks repairs to equipment and a sub form (datasheet) which displays all the various repairs to a particular item of equipment.

I am trying to have the main form update when the user clicks on a line in the sub form.

The main form and sub form are linked by a field "maintenanceitem". I have used this so it shows all records relating to that type of equipment in the sub form.

My code to update the main form form the sub form is:

Forms!FrmRepairsView.Filter = "Id=" & Me.ID
Forms!FrmRepairsView.FilterOn = True
Forms!FrmRepairsView.Requery

When I select a record in the sub form, the filter applies to the main form but then Access crashes, restarts and brings up the create backup screen!

Would appreciate any assistance with this.

Thanks

David
 

Micron

AWF VIP
Local time
Today, 13:30
Joined
Oct 20, 2018
Messages
3,408
If the forms are "linked" via maintenanceitem then shouldn't you just rely on the link Master and Child fields properties of the form?
I'm not getting the full picture though. Maintenance and reliability was a big part of my career and it all revolved around equipment as the parent thing and all maintenance related activities as the child records of it. Thus I'm not understanding the notion of 'updating' the main record by doing anything to the subform records. The crash might be related to imposing filters that clash with the master/child settings assuming you're using both, but that's just a guess. I didn't want to jump on the 'corruption' train just yet.

EDIT - BTW, a requery will reload the form with the effect of making the current record the first in the recordset. That is also a possible reason for a crash because that first record may not have anything to do with your subform record being displayed just before that. If it seems like I'm speculating, I am, given that a lot of things can cause this, and not being able to see the db is a bit of a shortcoming.
 
Last edited:

Drand

Registered User.
Local time
Tomorrow, 03:30
Joined
Jun 8, 2019
Messages
51
Basically what I am trying to do is this.

I link the forms by maintenanceitem as it will have many instances of repair, all of which I want to display on the subform. The main form is filtered by this field.

Each record on the main form may or may not have an attachment (repair invoice pdf). So what I want the user to do is to click on a record in the subform which in turn will display the corresponding main form and then the user can see if an invoice is attached.
 

Drand

Registered User.
Local time
Tomorrow, 03:30
Joined
Jun 8, 2019
Messages
51
Basically what I am trying to do is this.

I link the forms by maintenanceitem as it will have many instances of repair, all of which I want to display on the subform. The main form is filtered by this field.

Each record on the main form may or may not have an attachment (repair invoice pdf). So what I want the user to do is to click on a record in the subform which in turn will display the corresponding main form and then the user can see if an invoice is attached.
Sorry Micron

I solved this by simply displaying the invoice attachment in the sub form which works just as well. Sometime I just try to make things too complicated!!!

Many thanks for you reply. I do appreciate it,

Cheers
 

Micron

AWF VIP
Local time
Today, 13:30
Joined
Oct 20, 2018
Messages
3,408
NP. Glad you were able to solve it, but I guess we won't know the actual cause now.
Sounds like you are storing attachments in your tables - might want to rethink that if so.
 

arnelgp

error reading drive A:
Local time
Tomorrow, 01:30
Joined
May 7, 2009
Messages
9,925
if ID in main form is autonumber and the ID in the subform is also autonumber,
then you are in the wrong track my friend.
that maybe the cause why your db is restarting.
you need to add a Foreign key to your subform's table.
this will be a Long integer that will point the the "Headers" ID field.

you do not need to use Filter on the subform.
use the subform's Link Master/Child Fields Property so
your subform's data get "sync" with the main form.

on design view, click on your subform.
make sure a a rectangle appears surrounding
the subform.
on it's Property->Data:

Link Master Fields: ID
Link Child Fields: [the FK of your table]
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom