Free Code Snippets in C#, Net Framework, Office 365, ASP.Net,WPF, Visual Studio, SQL Server, Antivirus free
#

 

 

This error occurs in Microsoft Office applications when in the vba code a variable has no value and should be transferred to another location.

 

In this example, if the variable varSTring was never used and therefore has the value zero, then it can not be applied to test.

Test= varString

 

When you take values from a database or recordset, it is common.

lblHead_Bauvorhaben.Caption = recHeader("Bauvorhaben")

 

Solution:

You have to enclose the emergency-zero function with the transfer. This function nz (variable, new_value) states that if the variable is zero then another default value should be adopted.

This means in the example the function nz (variable, "") transfers a space if there is no value.

lblHead_Bauvorhaben.Caption = Nz(recHeader("Bauvorhaben"), "")

 

In vba code page

 

Example of the correction when data is taken from a recordset by Access

Private Sub fl_Load_Header()

    '--------------------< fl_Load_Header() >--------------------

    Dim ID_Projekt As Long

    ID_Projekt = Form_frm_Projekte.ctlListe

 

 

    Dim recHeader As Recordset

    Set recHeader = CurrentDb.OpenRecordset("SELECT * FROM tbl_Projekte WHERE ID_Projekt=" & Form_frm_Projekte.ctlListe, dbOpenSnapshot)

    If Not recHeader.EOF Then

        lblHead_ID_Projekt.Caption = ID_Projekt

        lblHead_Bauvorhaben.Caption = Nz(recHeader("Bauvorhaben"), "")

        lblHead_Kunde.Caption = recHeader("Kunde_Firmenname")

        lblHead_Datum_Projekt.Caption = Nz(recHeader("Datum_Projekt"), "")

    End If

    recHeader.Close

 

    '--------------------</ fl_Load_Header() >--------------------

End Sub

 

Mobile
»
Access Error: This record has been modified by another user since editing began.
»
Error Code 94: Invalid Use of Null
»
Access Error message: Missing reference to OWC10.DLL

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de