Results 1 to 6 of 6
  1. #1
    Z1nkstar's Avatar
    Z1nkstar is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Location
    TX, USA
    Posts
    145

    Run-time error '94'

    Invalid use of Null

    I don't believe I even used null in this sequence?


    Click image for larger version. 

Name:	fghijklmn.jpg 
Views:	6 
Size:	190.3 KB 
ID:	16102Click image for larger version. 

Name:	jklmnopqrstuvwxyzz.jpg 
Views:	6 
Size:	147.8 KB 
ID:	16103

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    NewPos is an integer. Integers can not accept Null

    Apparently, the field AllSort does not have a value. You can not do math on Null. Null + 1 = Null

    You will need to do data validation of the field/control before assigning it to an integer variable.

  3. #3
    Z1nkstar's Avatar
    Z1nkstar is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Location
    TX, USA
    Posts
    145
    So how can I set the value?
    All I need is it to ascend starting at 1 in the sort column???

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I do not know your data and your objective but, you can set a default value of 0 to your control and or field. This will likely avoid the error, at least in most cases.

  5. #5
    Z1nkstar's Avatar
    Z1nkstar is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Location
    TX, USA
    Posts
    145
    well it is a number field and it doesnt have any set value but i put in default to 0 but that won't fill in the records that are currently there

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe validate the field in your code.
    If isnull(Me!AllSort.Value) then
    Me!AllSort.Value = 0
    End if

    You could run an UPDATE query to change the Null fields to equal zero.

    Make a copy to test new and radical action queries like UPDATE queries. Make sure you do not destroy your table.

    The query builder could guide you. Your UPDATE query could include criteria to only retrieve Is Null for that field. Then, in the Update To field you would place 0.

    The fact that it is a number field makes things a little easier. You just need to make sure that the default value of zero is never erased. For instance, if there is a control on a form that is bound to AllSort, a user may be able to delete the value, save the record, and levae the field as Null.

    Giving it a default value is not enough alone. You need to maintain constraints so there is not the possibility it will become Null, at least not be Null just before your code runs.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  2. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  3. Replies: 0
    Last Post: 07-16-2012, 05:42 AM
  4. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  5. Replies: 5
    Last Post: 03-27-2012, 01:40 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums