Access – Forms Coding

D

David Cleave

I have a subform that gets requeried by the Current event of another subform
(I’m trying to link the data between them). The code used is as follows:

[Forms]![FormName]![SubformName].Form.Requery

This works fine except in one instance. When the parent form opens, I get
this error:

Run-time error ‘2455’:

You entered an expression which has an invalid reference to the property
Form/Report.

I assume this is because the Current event is being called before the second
subform is loaded (and can therefore be requeried). Can anyone confirm if
this assumption is correct?

If it is, how can I test whether the subform is ready to be requeried so
that I can avoid the error? If the assumption is wrong, can anyone provide me
with another solution?

Thanks

David
 
A

Allen Browne

Yes, your assumption sounds correct.

Just use error handling to ignore that error number.
 
D

David Cleave

Thanks for your help Allen.

Can you tell me how to ignore an error? Sounds very useful...

Allen Browne said:
Yes, your assumption sounds correct.

Just use error handling to ignore that error number.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

David Cleave said:
I have a subform that gets requeried by the Current event of another
subform
(I'm trying to link the data between them). The code used is as follows:

[Forms]![FormName]![SubformName].Form.Requery

This works fine except in one instance. When the parent form opens, I get
this error:

Run-time error '2455':

You entered an expression which has an invalid reference to the property
Form/Report.

I assume this is because the Current event is being called before the
second
subform is loaded (and can therefore be requeried). Can anyone confirm if
this assumption is correct?

If it is, how can I test whether the subform is ready to be requeried so
that I can avoid the error? If the assumption is wrong, can anyone provide
me
with another solution?

Thanks

David
 
G

Geof Wyght

David,
I would try to avoid the runtime error. What event is the
Requery in?
Geof.
 
D

David Cleave

Hi Geof

Thanks for your response. The Current Event of Subform 1 requeries Subform 2.

David

Geof Wyght said:
David,
I would try to avoid the runtime error. What event is the
Requery in?
Geof.
-----Original Message-----
I have a subform that gets requeried by the Current event of another subform
(Iâ?Tm trying to link the data between them). The code used is as follows:

[Forms]![FormName]![SubformName].Form.Requery

This works fine except in one instance. When the parent form opens, I get
this error:

Run-time error â?~2455â?T:

You entered an expression which has an invalid reference to the property
Form/Report.

I assume this is because the Current event is being called before the second
subform is loaded (and can therefore be requeried). Can anyone confirm if
this assumption is correct?

If it is, how can I test whether the subform is ready to be requeried so
that I can avoid the error? If the assumption is wrong, can anyone provide me
with another solution?

Thanks

David

.
 
G

Geof Wyght

David,
How about Me.Parent.Name ? If the subform is open you'll
get a name, otherwise you will get a runtime error (which
can be trapped). Or how about testing for EOF of the
recordset of the 2nd subform?
Geof.
-----Original Message-----
Hi Geof

Thanks for your response. The Current Event of Subform 1 requeries Subform 2.

David

Geof Wyght said:
David,
I would try to avoid the runtime error. What event is the
Requery in?
Geof.
-----Original Message-----
I have a subform that gets requeried by the Current
event
of another subform
(Iâ?Tm trying to link the data between them). The
code
used is as follows:
[Forms]![FormName]![SubformName].Form.Requery

This works fine except in one instance. When the
parent
form opens, I get
this error:

Run-time error â?~2455â?T:

You entered an expression which has an invalid
reference
to the property
Form/Report.

I assume this is because the Current event is being called before the second
subform is loaded (and can therefore be requeried).
Can
anyone confirm if
this assumption is correct?

If it is, how can I test whether the subform is ready
to
be requeried so
that I can avoid the error? If the assumption is
wrong,
can anyone provide me
with another solution?

Thanks

David

.
.
 
D

Dan Artuso

Hi,
All your routines should have error handlers.
You can name the handler whatever you want,
current_err was my arbitrary choice.

Private Sub Form_Current()
On Error GoTo current_err
'some code to do stuff
'
'
Exit Sub

current_err:
If err.Number <> 2455 Then
MsgBox "there was an error in the current event: " & err.Description & " number: " & err.Number
End If

End Sub

--
HTH
Dan Artuso, Access MVP


David Cleave said:
Thanks for your help Allen.

Can you tell me how to ignore an error? Sounds very useful...

Allen Browne said:
Yes, your assumption sounds correct.

Just use error handling to ignore that error number.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

David Cleave said:
I have a subform that gets requeried by the Current event of another
subform
(I'm trying to link the data between them). The code used is as follows:

[Forms]![FormName]![SubformName].Form.Requery

This works fine except in one instance. When the parent form opens, I get
this error:

Run-time error '2455':

You entered an expression which has an invalid reference to the property
Form/Report.

I assume this is because the Current event is being called before the
second
subform is loaded (and can therefore be requeried). Can anyone confirm if
this assumption is correct?

If it is, how can I test whether the subform is ready to be requeried so
that I can avoid the error? If the assumption is wrong, can anyone provide
me
with another solution?

Thanks

David
 
D

David Cleave

Hi Geof

Thanks for these excellent suggestions. At the moment I have opted to
crudely circumvent the problem but using On Error Resume Next to ignore any
errors generated by the Requery statement. If I find I need to be more
specific about which errors I ignore (rather than just ignoring all errors),
I will try these.

Cheers

David

Geof Wyght said:
David,
How about Me.Parent.Name ? If the subform is open you'll
get a name, otherwise you will get a runtime error (which
can be trapped). Or how about testing for EOF of the
recordset of the 2nd subform?
Geof.
-----Original Message-----
Hi Geof

Thanks for your response. The Current Event of Subform 1 requeries Subform 2.

David

Geof Wyght said:
David,
I would try to avoid the runtime error. What event is the
Requery in?
Geof.
-----Original Message-----
I have a subform that gets requeried by the Current event
of another subform
(Iâ?Tm trying to link the data between them). The code
used is as follows:

[Forms]![FormName]![SubformName].Form.Requery

This works fine except in one instance. When the parent
form opens, I get
this error:

Run-time error â?~2455â?T:

You entered an expression which has an invalid reference
to the property
Form/Report.

I assume this is because the Current event is being
called before the second
subform is loaded (and can therefore be requeried). Can
anyone confirm if
this assumption is correct?

If it is, how can I test whether the subform is ready to
be requeried so
that I can avoid the error? If the assumption is wrong,
can anyone provide me
with another solution?

Thanks

David

.
.
 

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