Results 1 to 4 of 4
  1. #1
    Steven19 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2020
    Location
    London
    Posts
    110

    Invalid Use of Null

    So I get the Invalid Use of Null, but am not familiar with fixing this. My code is thus:



    Private Sub SaveBtn_Click()
    Dim rs As Recordset, x As Integer
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM Seals WHERE 1=0")
    For x = Me.StartRange To Me.EndRange
    rs.AddNew
    rs!BoltNum = Me.Prefix & x
    rs!BoxID = Me.Box_ID
    rs!SealTypes = Me.Seal_Types
    rs!SupplierLookup = Me.Supplier
    rs!DateAdded = Me.Date_Added
    rs!Site = Me.Site
    rs.Update
    Next

    For x = Me.StartRange To Me.EndRange is highlighted as Invalid use of Null when these fields are unbound.

    If I set their Control Source to the fields for them, then I end up with data in the fields StartRange and EndRange, and I dont need that.

    I need a solution so that when I send the database to a colleague they can start with field 1 bland, and not have error 94 come up.

    Help much appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,901
    What value do you want to provide if null - 1?

    For x = Nz(Me.StartRange, 1) To Nz(Me.EndRange, 1)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Steven19 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2020
    Location
    London
    Posts
    110
    the thing is, the fields are never null., I'm always entering data here, the bolts will always hav a range, a start number in sequece to several hundred. Its just strange that access thinks there is no data here when creating the first record.

    So I enter test data 3 for start and 7 for end and it saves those values in my table, in the first row all the time, I have to overwrite it all the time, but the rest of the code works as expected.

  4. #4
    Steven19 is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Jun 2020
    Location
    London
    Posts
    110
    thats a good fix thank you.
    Just when adding the amendment I keep forgetting I have to save, close it out and re-start it again for it to take hold.
    THanks for your help.

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

Similar Threads

  1. Invalid Use Of Null
    By johndoe123 in forum Programming
    Replies: 1
    Last Post: 05-13-2019, 11:40 AM
  2. Replies: 4
    Last Post: 04-09-2019, 02:05 PM
  3. Replies: 3
    Last Post: 11-13-2013, 08:56 AM
  4. Invalid use of Null
    By justauser in forum Forms
    Replies: 2
    Last Post: 11-28-2012, 12:33 PM
  5. Invalid Use of Null!?!
    By Kipster1203 in forum Access
    Replies: 4
    Last Post: 05-13-2010, 06:09 AM

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