Freelance Project Requests Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net



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")



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



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

End Sub




Contact for Jobs, Project Requests: