Connecting Tech Pros Worldwide Forums | Help | Site Map

a2k - irritating RI message

Deano
Guest
 
Posts: n/a
#1: Nov 12 '05
My form is set up so that if I add a record to my main form, a related
record is created in the subform. This occurs in the afterupdate event of
my main control.

I have made a few changes here, nothing in my opinion that would cause a
problem.

Now if I delete a main record and exit the form I am greeted with this
message;

You cannot add or change a record because a related record is required in
table 'tblmain'

The records and data therein are all OK after the deletion.

Why is this message occurring? Am I missing some basic protocol I should be
following? If not how can I suppress this message?

tia
Martin



TC
Guest
 
Posts: n/a
#2: Nov 12 '05

re: a2k - irritating RI message


The deletion of the main record is firing the code that tries to add a
record to the subform?

HTH,
TC


"Deano" <deanma66999@hotmail.com> wrote in message
news:mKPAb.18474$lm1.155177@wards.force9.net...[color=blue]
> My form is set up so that if I add a record to my main form, a related
> record is created in the subform. This occurs in the afterupdate event of
> my main control.
>
> I have made a few changes here, nothing in my opinion that would cause a
> problem.
>
> Now if I delete a main record and exit the form I am greeted with this
> message;
>
> You cannot add or change a record because a related record is required in
> table 'tblmain'
>
> The records and data therein are all OK after the deletion.
>
> Why is this message occurring? Am I missing some basic protocol I should[/color]
be[color=blue]
> following? If not how can I suppress this message?
>
> tia
> Martin
>
>[/color]


Deano
Guest
 
Posts: n/a
#3: Nov 12 '05

re: a2k - irritating RI message


TC wrote:[color=blue]
> The deletion of the main record is firing the code that tries to add a
> record to the subform?
>
> HTH,
> TC[/color]


That did help TC. I started looking for some code and found a line that
executes the lostfocus event of a control in a subform.

This was introduced because of validation problems - I found I got a 2455
error when the lostfocus event fired on that control after having clicked
the Delete button, whereby Access claims i've put in an incorrect reference
(when I know full well this isn't the case).

One idea round this was to deliberately call the lostfocus event first in
the Delete button, but before the actual delete code. The 2455 error then
doesn't occur but then the error mentioned in my first post does.

Now that i've stopped calling that lostfocus event, it no longer appears.

This still means i have to rethink my validation and perhaps which buttons I
make available to the user. I do find that some of the interfaces I want to
implement just aren't catered for by the controls and their properties and I
have to resort to extreme workarounds and then wander into these bear traps.
<begins to sulk>


[color=blue]
>
>
> "Deano" <deanma66999@hotmail.com> wrote in message
> news:mKPAb.18474$lm1.155177@wards.force9.net...[color=green]
>> My form is set up so that if I add a record to my main form, a
>> related record is created in the subform. This occurs in the
>> afterupdate event of my main control.
>>
>> I have made a few changes here, nothing in my opinion that would
>> cause a problem.
>>
>> Now if I delete a main record and exit the form I am greeted with
>> this message;
>>
>> You cannot add or change a record because a related record is
>> required in table 'tblmain'
>>
>> The records and data therein are all OK after the deletion.
>>
>> Why is this message occurring? Am I missing some basic protocol I
>> should be following? If not how can I suppress this message?
>>
>> tia
>> Martin[/color][/color]



TC
Guest
 
Posts: n/a
#4: Nov 12 '05

re: a2k - irritating RI message


Hi Martin

Glad that helped.

TC


"Deano" <deanma66999@hotmail.com> wrote in message
news:J7RAb.18493$lm1.155307@wards.force9.net...[color=blue]
> TC wrote:[color=green]
> > The deletion of the main record is firing the code that tries to add a
> > record to the subform?
> >
> > HTH,
> > TC[/color]
>
>
> That did help TC. I started looking for some code and found a line that
> executes the lostfocus event of a control in a subform.
>
> This was introduced because of validation problems - I found I got a 2455
> error when the lostfocus event fired on that control after having clicked
> the Delete button, whereby Access claims i've put in an incorrect[/color]
reference[color=blue]
> (when I know full well this isn't the case).
>
> One idea round this was to deliberately call the lostfocus event first in
> the Delete button, but before the actual delete code. The 2455 error then
> doesn't occur but then the error mentioned in my first post does.
>
> Now that i've stopped calling that lostfocus event, it no longer appears.
>
> This still means i have to rethink my validation and perhaps which buttons[/color]
I[color=blue]
> make available to the user. I do find that some of the interfaces I want[/color]
to[color=blue]
> implement just aren't catered for by the controls and their properties and[/color]
I[color=blue]
> have to resort to extreme workarounds and then wander into these bear[/color]
traps.[color=blue]
> <begins to sulk>
>
>
>[color=green]
> >
> >
> > "Deano" <deanma66999@hotmail.com> wrote in message
> > news:mKPAb.18474$lm1.155177@wards.force9.net...[color=darkred]
> >> My form is set up so that if I add a record to my main form, a
> >> related record is created in the subform. This occurs in the
> >> afterupdate event of my main control.
> >>
> >> I have made a few changes here, nothing in my opinion that would
> >> cause a problem.
> >>
> >> Now if I delete a main record and exit the form I am greeted with
> >> this message;
> >>
> >> You cannot add or change a record because a related record is
> >> required in table 'tblmain'
> >>
> >> The records and data therein are all OK after the deletion.
> >>
> >> Why is this message occurring? Am I missing some basic protocol I
> >> should be following? If not how can I suppress this message?
> >>
> >> tia
> >> Martin[/color][/color]
>
>
>[/color]


Closed Thread