Subform Reference problem

  • Thread starter Thread starter Mark A. Sam
  • Start date Start date
M

Mark A. Sam

Sometimes, not always I get this error when on this line in my Current Event
of a main form....

[PickUps].Form![ViewLogChanges].Visible = Nz((GetUserLevel() = "Admin"),
False)

Runtime error '2455': You entered an expression which has an invalid
reference to the property Form/Report.

[Pickups] is a subform
[ViewLogChanges] is a command button on the subform

Nz((GetUserLevel() = "Admin"), False) = True

GetUserLevel = "Admin"


GetUserLevel can return a string, "User" or "Admin" or the value Null. Then
GetUserLevel = Null the problem doesn't seem to occur. It seems to occur
when GetUserLevel is Not Null.

Here is GetUserLevel

Public Function GetUserLevel()

If RequireLogin = False Then
GetUserLevel = "Admin"
Else
GetUserLevel = Nz(DLookup("[level]", "loginUsers", "[UserName] = '" &
pubLoggedUser & "'"), Null)
End If

End Function

Thanks for any help.

God Bless,

Mark A. Sam
 
Your subform reference is incomplete. Use:

Me!PickUps.Form![ViewLogChanges].Visible = Nz((GetUserLevel() = "Admin")

Or

Forms!NameOfMainform!PickUps.Form![ViewLogChanges].Visible =
Nz((GetUserLevel() = "Admin")
 
PC,

Thanks for the response, but neither of those methods works. I have never
seen where I needed to reference the Me object.

The problems seems to be the value of a public Variant type variable called
pubLoggedUser having a value other then Null. When I assign a value to
pubLoggedUser the the reference bombs out. When I assign it a Null value
there is no problem. I took the function GetUserLevel()
out of the picture and simply said...

[PickUps].Form![ViewLogChanges].Visible = True

This works fine when pubLoggedUser = Null.

God Bless,

Mark



PC Datasheet said:
Your subform reference is incomplete. Use:

Me!PickUps.Form![ViewLogChanges].Visible = Nz((GetUserLevel() = "Admin")

Or

Forms!NameOfMainform!PickUps.Form![ViewLogChanges].Visible =
Nz((GetUserLevel() = "Admin")


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com



Mark A. Sam said:
Sometimes, not always I get this error when on this line in my Current Event
of a main form....

[PickUps].Form![ViewLogChanges].Visible = Nz((GetUserLevel() = "Admin"),
False)

Runtime error '2455': You entered an expression which has an invalid
reference to the property Form/Report.

[Pickups] is a subform
[ViewLogChanges] is a command button on the subform

Nz((GetUserLevel() = "Admin"), False) = True

GetUserLevel = "Admin"


GetUserLevel can return a string, "User" or "Admin" or the value Null. Then
GetUserLevel = Null the problem doesn't seem to occur. It seems to occur
when GetUserLevel is Not Null.

Here is GetUserLevel

Public Function GetUserLevel()

If RequireLogin = False Then
GetUserLevel = "Admin"
Else
GetUserLevel = Nz(DLookup("[level]", "loginUsers", "[UserName] = '" &
pubLoggedUser & "'"), Null)
End If

End Function

Thanks for any help.

God Bless,

Mark A. Sam
 
From the Help file ---

To refer to a subform or subreport
Refer to the subform or subreport control on the form or report that
contains the subform or subreport, then use the Form or Report property of
the control to refer to the actual subform or subreport.

· Type the identifier for the form that contains the subform, followed by
the name of its subform control, the . (dot) operator, and the Form
property. For example, the following identifier refers to the Orders Subform
subform on the Orders form:

Forms![Orders]![Orders Subform].Form

The Me property contains an object reference to the current form or report
and is faster than a fully qualified object reference. For example, the
following two code fragments refer to the value of the LastName control for
the current record on the Employees form:

strLastName = Forms!Employees.LastName

strLastName = Me!LastName




Mark A. Sam said:
PC,

Thanks for the response, but neither of those methods works. I have never
seen where I needed to reference the Me object.

The problems seems to be the value of a public Variant type variable called
pubLoggedUser having a value other then Null. When I assign a value to
pubLoggedUser the the reference bombs out. When I assign it a Null value
there is no problem. I took the function GetUserLevel()
out of the picture and simply said...

[PickUps].Form![ViewLogChanges].Visible = True

This works fine when pubLoggedUser = Null.

God Bless,

Mark



PC Datasheet said:
Your subform reference is incomplete. Use:

Me!PickUps.Form![ViewLogChanges].Visible = Nz((GetUserLevel() = "Admin")

Or

Forms!NameOfMainform!PickUps.Form![ViewLogChanges].Visible =
Nz((GetUserLevel() = "Admin")


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com



Mark A. Sam said:
Sometimes, not always I get this error when on this line in my Current Event
of a main form....

[PickUps].Form![ViewLogChanges].Visible = Nz((GetUserLevel() = "Admin"),
False)

Runtime error '2455': You entered an expression which has an invalid
reference to the property Form/Report.

[Pickups] is a subform
[ViewLogChanges] is a command button on the subform

Nz((GetUserLevel() = "Admin"), False) = True

GetUserLevel = "Admin"


GetUserLevel can return a string, "User" or "Admin" or the value Null. Then
GetUserLevel = Null the problem doesn't seem to occur. It seems to occur
when GetUserLevel is Not Null.

Here is GetUserLevel

Public Function GetUserLevel()

If RequireLogin = False Then
GetUserLevel = "Admin"
Else
GetUserLevel = Nz(DLookup("[level]", "loginUsers", "[UserName] = '" &
pubLoggedUser & "'"), Null)
End If

End Function

Thanks for any help.

God Bless,

Mark A. Sam
 
PC,

I'm not disputing that the forms you gave me are correct, but they didn't
solve the problem. I tried them both and still had the issue.

Thank you and God Bless,

Mark


PC Datasheet said:
From the Help file ---

To refer to a subform or subreport
Refer to the subform or subreport control on the form or report that
contains the subform or subreport, then use the Form or Report property of
the control to refer to the actual subform or subreport.

· Type the identifier for the form that contains the subform, followed by
the name of its subform control, the . (dot) operator, and the Form
property. For example, the following identifier refers to the Orders Subform
subform on the Orders form:

Forms![Orders]![Orders Subform].Form

The Me property contains an object reference to the current form or report
and is faster than a fully qualified object reference. For example, the
following two code fragments refer to the value of the LastName control for
the current record on the Employees form:

strLastName = Forms!Employees.LastName

strLastName = Me!LastName




Mark A. Sam said:
PC,

Thanks for the response, but neither of those methods works. I have never
seen where I needed to reference the Me object.

The problems seems to be the value of a public Variant type variable called
pubLoggedUser having a value other then Null. When I assign a value to
pubLoggedUser the the reference bombs out. When I assign it a Null value
there is no problem. I took the function GetUserLevel()
out of the picture and simply said...

[PickUps].Form![ViewLogChanges].Visible = True

This works fine when pubLoggedUser = Null.

God Bless,

Mark



PC Datasheet said:
Your subform reference is incomplete. Use:

Me!PickUps.Form![ViewLogChanges].Visible = Nz((GetUserLevel() = "Admin")

Or

Forms!NameOfMainform!PickUps.Form![ViewLogChanges].Visible =
Nz((GetUserLevel() = "Admin")


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com



Sometimes, not always I get this error when on this line in my Current
Event
of a main form....

[PickUps].Form![ViewLogChanges].Visible = Nz((GetUserLevel() = "Admin"),
False)

Runtime error '2455': You entered an expression which has an invalid
reference to the property Form/Report.

[Pickups] is a subform
[ViewLogChanges] is a command button on the subform

Nz((GetUserLevel() = "Admin"), False) = True

GetUserLevel = "Admin"


GetUserLevel can return a string, "User" or "Admin" or the value Null.
Then
GetUserLevel = Null the problem doesn't seem to occur. It seems to occur
when GetUserLevel is Not Null.

Here is GetUserLevel

Public Function GetUserLevel()

If RequireLogin = False Then
GetUserLevel = "Admin"
Else
GetUserLevel = Nz(DLookup("[level]", "loginUsers", "[UserName] =
'"
 
Back
Top