I use macros from example in this post from file Open_Form_Filtered.odb, … but…
What if I don’t have filtered record in other form (no relation data created) … I need macro to open filtered data in another form or to create new record if data is not existend … well I can add data to opened form, but trouble is listbox in which if I select data (for new record) I get error, and nothing is entered (unless I disable macro for listbox)
So in short, error in on new record in listbox …
Now I use this…
Sub Otvori_Upisni_List_iz_Maticnog_Lista (oEvent As Object) 'This opens another form with filtered data
oForm = oEvent.Source.Model.Parent
iID=oForm.getByName("ID_Maticni").text
oForm2 = ThisDatabaseDocument.FormDocuments.getByName("Upisni")
oForm2.Open
oForm3 = oForm2.Component.DrawPage.Forms.getByName("Upisni_List")
oForm3.Filter="( ""UPISNI_LIST"".""FK_Maticni"" = " & iID & " )"
oForm3.ApplyFilter=True
oForm3.Reload()
end sub
Sub Refresh_MainForm (oEvent As Object) 'List Box > Execute (event)
oForm = oEvent.Source.Model.Parent
oEvent.Source.Model.commit()
oForm.updateRow() 'this is point where I get error when entering data to new record via listbox, ... changing data on existing records works fine
oForm.reload
End Sub