Results 1 to 8 of 8

Thread: Null Value

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Oak Creek, WI, USA
    Posts
    92
    What would create an "Invalid use of Null" error? Seemingly the particular field in question has the same settings as the rest (access 2000), required no, allow zero length yes, indexed no. Also, it is not a primary key. I don't want to check for a null value or some type of work around, to me, it seems this should not happen. Is it a bug? ie. what causes this? Anyone?

    Thanks,

    casox

    [Edited by casox on 03-22-2000 at 11:43 AM]

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Oshkosh, WI
    Posts
    163
    If the field is not required and is not filled in then it will be NULL.

    Handling the null should not be considered a workaround, you should consider it good database programming

    [Edited by Glenn on 03-22-2000 at 12:41 PM]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Oak Creek, WI, USA
    Posts
    92
    I have 42 fields, 39 of which are currently not filled and not required, only the one in question gives me an Invalid use of Null, the others are fine. I understand that it is a null value, however, my question is why would the use of one particular null value be invalid, while others which are seemingly being handled the same way are without error? Ponimaesh? Verstace?

    casox

    [Edited by casox on 03-22-2000 at 01:43 PM]

  4. #4
    Addicted Member pardede's Avatar
    Join Date
    Jan 2000
    Posts
    232
    sometimes its a matter of which datatype the field has, or whether any function is used on the value, or if any comparison was done... posting your code might clarify the situation?

    [Edited by pardede on 03-23-2000 at 06:26 PM]

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Oak Creek, WI, USA
    Posts
    92
    Here's a sample of my code. The table is in Access 2000. All of the fields are of type text, all of their attributes are identical, on the surface that is. There are no functions applied to any of them and no comparisons have been done with the one in question. Can anyone help me dig further? Thanks.

    casox

    Private Sub display()

    'Refreshes screen if records exist

    If InventoryTB.RecordCount > 0 Then

    'Checks for beginning of file

    If InventoryTB.EOF Then

    InventoryTB.MoveLast
    MsgBox ("You've reached the last record in the file."), vbInformation

    End If

    'Checks for end of file

    If InventoryTB.BOF Then

    InventoryTB.MoveFirst
    MsgBox ("You've reached the first record in the file."), vbInformation

    End If

    txtLocation.Text = InventoryTB!Location
    txtAssignedTo.Text = InventoryTB!EmployeeName ' Gives me Invalid use of null
    cmbDescrip.Text = InventoryTB!Description
    cmbModel.Text = InventoryTB!ModelNum
    txtModelSerialNum.Text = InventoryTB!ModelSerialNum
    txtModelAssetNum.Text = InventoryTB!ModelAssetNum
    cmbEthernetLan.Text = InventoryTB!EthernetLan
    cmbMonitor.Text = InventoryTB!Monitor
    txtMonitorSerialNum.Text = InventoryTB!MonitorSerialNum
    txtMonitorAssetNum.Text = InventoryTB!MonitorAssetNum
    txtNetworkName.Text = InventoryTB!NetworkName
    txtIPAddress.Text = InventoryTB!IPAddress
    cmbAcquisition = InventoryTB!Acquisition
    cmbCDRom.Text = InventoryTB!CDRom
    cmbZip.Text = InventoryTB!ZipDrive
    txtZipSerialNum.Text = InventoryTB!ZipSerialNum
    txtZipAssetNum.Text = InventoryTB!ZipAssetNum
    cmbTape.Text = InventoryTB!TapeDrive
    txtTapeSerialNum.Text = InventoryTB!TapeSerialNum
    txtTapeAssetNum.Text = InventoryTB!TapeAssetNum
    cmbJazz.Text = InventoryTB!JazzDrive
    txtJazzSerialNum.Text = InventoryTB!JazzSerialNum
    txtJazzAssetNum.Text = InventoryTB!JazzAssetNum
    cmbKeyboard.Text = InventoryTB!Keyboard
    txtRAM.Text = InventoryTB!RAM
    txtHardDrive.Text = InventoryTB!HardDrive
    cmbOPSystem.Text = InventoryTB!OperatingSystem
    cmbMouse.Text = InventoryTB!Mouse

    cmdAddRecord.Enabled = True
    cmdDeleteRecord.Enabled = True
    cmdGotoRecord.Enabled = True
    cmdUpdateRecord.Enabled = True
    cmdSearchRecords.Enabled = True
    cmdQuit.Enabled = True
    cmdSaveRecord.Enabled = False
    cmdCancel.Enabled = False

    End If


    End Sub

  6. #6
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    do this:

    txtAssignedTo.Text = InventoryTB!EmployeeName & ""


    You won't get invalid use of null if you use this as a standard.

  7. #7
    Addicted Member pardede's Avatar
    Join Date
    Jan 2000
    Posts
    232
    I agree with JHaussman, that's really the simplest way to prevent the null value error.

    Still it intrigues/puzzles me as to why this happens. Having seen your code I don't think the problem is in the db-field cause what the code was trying to do is setting the text of a control to Null, and it refuses, quiet logical really. But why is there no problem with the other fields? Are their values never Null, in other words they contain nullstring ("") when empty? Or is there something special about the control "txtAssignedTo"? Maybe you should look at that.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Oak Creek, WI, USA
    Posts
    92
    Thanks for the help. Yes, it intrigues me also. There really is nothing special about the particular field. I don't know?!?!?!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width