Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2005

Tip: Looking for answers? Try searching our database.

Returning invalid use of Null error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bizpro - 23 Jul 2005 11:55 GMT
Hi All,

I have an issue with an If statement.
The scenario:
for a current client, the user double clicks a client namein a listbox - the
client file opens. Fields on the form are visible according to client type.
Create an new client, open form called clienttype select type from option
frame, on click open client form in dataentry mode with fields hidden or
visible according to client type.

The problem:

On execution of the code, the open new client scenario works, however
opening an existing client has an error 94 message "invalid use of null". I
tried to get around it with a GoTo statement but it hasn't helped. The error
is occuring immediately after the End If statement. What should I have in my
syntax if the form is to load without the clienttype form being open?

Private Sub Form_Load()
If CurrentProject.AllForms(ClientType).IsLoaded Then
  If Forms!ClientType.Frame1 = 2 Then Me.Check109.DefaultValue = True Else
Me.Check109.DefaultValue = False
 Else: GoTo 100
End If
100
   Me.Combo85.Visible = (Check109 = False)
   Me.DOB.Visible = (Check109 = False)
   Me.FirstName.Visible = (Check109 = False)
   Me.MiddleNames.Visible = (Check109 = False)
   Me.LastName.Visible = (Check109 = False)
   Me.Text113.Visible = (Check109 = True)

End Sub
RoyVidar - 23 Jul 2005 12:06 GMT
bizpro wrote in message
<2709EC8E-5BFC-45F4-813A-23CA13CF1540@microsoft.com> :
> Hi All,
>
[quoted text clipped - 29 lines]
>
> End Sub

Could it be because you are assigning defaultvalue to the checkbox
and not value?

Also the code toggling the visible property of the controls will be
executed regardless of the criterions above, is that the intention?

Signature

Roy-Vidar

bizpro - 23 Jul 2005 12:20 GMT
Thanks for your response.

Assigning a value instead of a defaultvalue doesn't make any difference to
the later error.
And yes, the toggling needs to run based on the client type of the existing
client when the form opens.

Essentially the problem only occurs when an existing client is actioned due
to the fact that the form "clienttype" is not loaded. This form is only
loaded if a new client is created.

> bizpro wrote in message
> <2709EC8E-5BFC-45F4-813A-23CA13CF1540@microsoft.com> :
[quoted text clipped - 37 lines]
> Also the code toggling the visible property of the controls will be
> executed regardless of the criterions above, is that the intention?
RoyVidar - 23 Jul 2005 12:54 GMT
bizpro wrote in message
<24177C25-BD4D-46EF-B9B1-7AFC1B055C4D@microsoft.com> :
> Thanks for your response.
>
[quoted text clipped - 49 lines]
>> Also the code toggling the visible property of the controls will be
>> executed regardless of the criterions above, is that the intention?

As far as I can see, your error occurs because the checbox is
Null when you try to use it's value to toggle the other controls
visible property.

Setting the defaultvalue, as you do if the other form is open,
seems to give the checkbox a value, but since you do not
assign neither defaultvalue nor value if the other form isn't
open, then the control will still be Null, causing the error in
the later assigning.

You will either need to assign a value to the control also
if the other form isn't open, or bind the checkbox to a field
in the forms recordsource or use something else to determine
what to assign the .visible property of the other controls.

Signature

Roy-Vidar

bizpro - 23 Jul 2005 13:21 GMT
Thanks Roy,

The checkbox is a bound control denoting client type and can not have a null
value based on the validation settings in the table. The weirdest thing
though, I removed the GoTo and just left the Else: and it now works
perfectly. Why it wouldn't do that for me earlier I don't know. Most
appreciative of your help.

> bizpro wrote in message
> <24177C25-BD4D-46EF-B9B1-7AFC1B055C4D@microsoft.com> :
[quoted text clipped - 66 lines]
> in the forms recordsource or use something else to determine
> what to assign the .visible property of the other controls.
bizpro - 24 Jul 2005 05:22 GMT
The saga continues. I have found the error lies in the fact that the first If
statement is returning a false value instead of True.

Private Sub Form_Load()

If CurrentProject.AllForms(ClientType).IsLoaded Then ...

This code is returning False even when the form ClientType is loaded.
Presumably it cannot see the form because of some setting I have applied,
however, I can't see what it might be.

> > >>> Private Sub Form_Load()
> > >>> If CurrentProject.AllForms(ClientType).IsLoaded Then
[quoted text clipped - 11 lines]
> > >>>
> > >>> End Sub
bizpro - 24 Jul 2005 05:27 GMT
Problem solved - I forgot the quote marks around the form name

> The saga continues. I have found the error lies in the fact that the first If
> statement is returning a false value instead of True.
[quoted text clipped - 22 lines]
> > > >>>
> > > >>> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.