Call to procedure messing me up!

Ali Edwards

Registered User.
Local time
Today, 19:48
Joined
Apr 19, 2001
Messages
68
Hi and please help as I'm very lost!!

I have a form [Main form], and subform [P1].

In the subform's Current and After Update events there is code: Call tablevisibility, which is a module containing the code:

Public Function TableVisibilty

dim tablevis As Variant

if not isnull ([Forms]![Main form]![P1]![Port 17 loss]) then
tablevis = 5

if not isnull ([Forms]![Main form]![P1]![Port 18 loss]) then
tablevis = 4

end if
end if

etc etc

if tablevis = 5 then
Forms![Main Form]![P1]![16 Port Reveal].Visible = false
f tablevis = 4 then
Forms![Main Form]![P1]![16 Port Reveal].Visible = true

end if
end if
etc etc

End Function

There is a lot more to the code but this will do in order for me to explain!

There is a delete button on the Main Form, which obviously deletes the record in the main form and all the records related to that record in the subform [P1].

The problem I have is that when I press the delete button I get the message:

Run Time error 2455
You entered an expression that has an invalid reference to the property form/report.

if I click Debug, the highlighted code is the first line of my module (as above) :-
if not isnull ([Forms]![Main form]![P1]![Port 17 loss] then
tablevis = 5.

Otherwise the procedure works OK, it's only when I delete a record from the main form.
I have tried setting warnings to false in both the delete button event and the module itself but that hasn't worked. Also I attempted error trapping but have limited knowledge on that!

Or is it possible to stop calling the TableVisibility module (which is called from the subform) when the delete button in the Main form is pressed, and resume after the record has been deleted??


Really grateful for any ideas!!



:confused:
 
are the controls you are referring to subforms
([Forms]![Main form]![P1]![Port 17 loss].form)
 
Hi,

I don't quite understand:

"are the controls you are referring to subforms"

The control (Port 17 loss) is a field on the subform [P1]. Am I not referring to it correctly?

Many thanks
Ali
 
Subform

The following is from the help screen Form Control:

The next two examples show how you might refer to a control named NewData on a subform ctlSubForm contained in the form called OrderForm:

Forms!OrderForm.ctlSubForm.Form!Controls.NewData
Forms!OrderForm.ctlSubForm!NewData

You are using a "!" instead of a "." between the main form name and the subform name. Replace the ! with a .
 
Aha!

Managed to get error trapping working which will do for now.

Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom