Problem with Button to reset the form

Never Hide

Registered User.
Local time
Today, 15:09
Joined
Dec 22, 2011
Messages
96
I'm running Access 2003 and I've created an unbound form in which I have a few comboboxes and textboxes and all of them are unbound. With the use of DLookup I "move around" the comboboxes(with the ID of 1 combobox I make a choice on another combobox etc). Also I have "cascading filterig" (I hope that makes sense,you make a selection in a combobox and based on that the list of the next combobox is limited) and I do that by changing the .Rowsource of the combobox. Everythig works gr8 when I first load the form. Poblems starts when I hit the reset button and try to start over. This is the code I have in the reset button On Click event.

Code:
Public Sub resetBTN_Click()
    'mhdenizei tis times se ola ta pedia ths formas
    Me.perifenot = Null
    Me.oikismos = Null
    Me.koinotita = Null
    Me.dimenot = Null
    Me.otaname = Null
    Me.pointx = Null
    Me.pointy = Null
    Me.LAT = Null
    Me.LON = Null
    Me.H = Null
    Me.hiddenota = Null
    Me.otaedra = Null
    Me.otaperif = Null

    'epanaferei to kathe combo box sthn arxikh tou morfh
    Me.oikismos.RowSource = "SELECT email_STAT_Oikismos_Ucase_Coords.Code_Kal, email_STAT_Oikismos_Ucase_Coords.Title_1, email_STAT_Oikismos_Ucase_Coords.POINT_X, email_STAT_Oikismos_Ucase_Coords.POINT_Y, email_STAT_Oikismos_Ucase_Coords.LAT, email_STAT_Oikismos_Ucase_Coords.LON, email_STAT_Oikismos_Ucase_Coords.H, email_STAT_Oikismos_Ucase_Coords.Parent_id_1, email_STAT_Oikismos_Ucase_Coords.Parent_Level " & _
                             "FROM email_STAT_Oikismos_Ucase_Coords " & _
                             "ORDER BY email_STAT_Oikismos_Ucase_Coords.Title_1;"
    Me.koinotita.RowSource = "SELECT email_STAT_Koinotita_Ucase.Code_Kal, email_STAT_Koinotita_Ucase.Title_1, email_STAT_Koinotita_Ucase.Parent_id_1, email_STAT_Koinotita_Ucase.Parent_Level " & _
                              "FROM email_STAT_Koinotita_Ucase " & _
                              "ORDER BY email_STAT_Koinotita_Ucase.Title_1;"

    Me.dimenot.RowSource = "SELECT email_STAT_Dim_Enotita_Ucase.Code_Kal, email_STAT_Dim_Enotita_Ucase.Title_1, email_STAT_Dim_Enotita_Ucase.OTA_id " & _
                            "FROM email_STAT_Dim_Enotita_Ucase " & _
                            "ORDER BY email_STAT_Dim_Enotita_Ucase.Title_1;"
    Me.otaname.RowSource = "SELECT email_STAT_OTA_Ucase.Code_Kal, email_STAT_OTA_Ucase.Title_1 " & _
                            "FROM email_STAT_OTA_Ucase " & _
                            "ORDER BY email_STAT_OTA_Ucase.Title_1;"

End Sub
When I make a selection in the "otaname" combobox I get an error:
Run-Time error '94':
Invalid use of Null
And when I select "Debug" I'm sent to the code of the AfterUpdate event of "otaname" the the red text is highlighted
P.S. I only get this error AFFTER I hit the reset button
Code:
Public Sub otaname_AfterUpdate()
    Dim otaID As String
    Dim perifenotID_2 As String
    Dim otaValue As String
    
    otaValue = Me.otaname.Value
    [COLOR=Red]perifenotID_2 = Me.otaname.Column(2)[/COLOR]
    otaID = Me.otaname.Column(0)
    
    Me.perifenot = DLookup("Code_Kal", "email_STAT_Per_Enotita_Ucase", "[Code_Kal]='" & perifenotID_2 & "'")
    perifenot_AfterUpdate
    Me.otaname = otaValue
    Me.hiddenota = DLookup("Code_Kal_OTA_STAT", "OTAs_Edres_STAT", "[Code_Kal_OTA_STAT]='" & otaID & "'")
    hiddenota_AfterUpdate
    'periorizei tis epiloges sto combo box "dimenot" se autes pou antistixoun ston epilegmeno ota
    If DCount("OTA_id", "email_STAT_Dim_Enotita_Ucase", "[OTA_id]='" & otaID & "'") >= 1 Then
        Me.dimenot.Value = Null
        Me.dimenot.RowSource = "SELECT email_STAT_Dim_Enotita_Ucase.Code_Kal, email_STAT_Dim_Enotita_Ucase.Title_1, email_STAT_Dim_Enotita_Ucase.OTA_id " & _
                                "FROM email_STAT_Dim_Enotita_Ucase " & _
                                "WHERE (((email_STAT_Dim_Enotita_Ucase.OTA_id) = [Forms]![Test_Form_1]![otaname])) " & _
                                "ORDER BY email_STAT_Dim_Enotita_Ucase.Title_1;"
    End If
   
    
    'periorizei tis epiloges sto combo box "koinotita" se autes pou antistixoun ston epilegmeno ota
    If DCount("Parent_id_1", "email_STAT_Koinotita_Ucase", "[Parent_id_1]='" & otaID & "'") >= 1 Then
        'Me.koinotita.Value = Null
        Me.koinotita.RowSource = "SELECT email_STAT_Koinotita_Ucase.Code_Kal, email_STAT_Koinotita_Ucase.Title_1, email_STAT_Koinotita_Ucase.Parent_id_1, email_STAT_Koinotita_Ucase.Parent_Level " & _
                                  "FROM email_STAT_Koinotita_Ucase " & _
                                  "WHERE (((email_STAT_Koinotita_Ucase.Parent_id_1) = [Forms]![Test_Form_1]![otaname])) " & _
                                  "ORDER BY email_STAT_Koinotita_Ucase.Title_1;"
    End If
    'periorizei tis epiloges sto combo box "oikismos" se autes pou antistixoun ston epilegmeno ota
    If DCount("Parent_id_1", "email_STAT_Oikismos_Ucase_Coords", "[Parent_id_1]='" & otaID & "'") >= 1 Then
        'Me.oikismos.Value = Null
        Me.oikismos.RowSource = "SELECT email_STAT_Oikismos_Ucase_Coords.Code_Kal, email_STAT_Oikismos_Ucase_Coords.Title_1, email_STAT_Oikismos_Ucase_Coords.POINT_X, email_STAT_Oikismos_Ucase_Coords.POINT_Y, email_STAT_Oikismos_Ucase_Coords.LAT, email_STAT_Oikismos_Ucase_Coords.LON, email_STAT_Oikismos_Ucase_Coords.H, email_STAT_Oikismos_Ucase_Coords.Parent_id_1, email_STAT_Oikismos_Ucase_Coords.Parent_Level " & _
                                  "FROM email_STAT_Oikismos_Ucase_Coords " & _
                                  "WHERE (((email_STAT_Oikismos_Ucase_Coords.Parent_id_1) = [Forms]![Test_Form_1]![otaname]))" & _
                                  "ORDER BY email_STAT_Oikismos_Ucase_Coords.Title_1;"
    
    End If

End Sub
In the code for the reset button I've also tried
Me.comboboxName.Value = Null
Me.comboboxName = ""
With the same results

I'm pretty sure that the problem is cause by the "Me.comboboxName = Null" (or any of the other options I've tried for that) I'm using in the reset button, but I don't know what to do :(

Let me know if you want me to post the rest of the code too, or if something is unclear they I put it here :)
Any suggestions/ideas/pointers are greatly appreciated
 
Last edited:

Users who are viewing this thread

Back
Top Bottom