treasureterew.blogg.se

Unipaas subfurm function
Unipaas subfurm function






So the key concept here is that you don’t need to pass the current active form since screenActive form will enable you to get the current form object anyway.

#Unipaas subfurm function code#

So note how we don’t need to pass the form name at all – the above code simply picks up the active screen as variable “f”.Īt that point you can do anything as if the code was inside the form. VbQuestion + vbYesNoCancel, "Delete?") = vbYes Then If MsgBox("Delete this " & strPrompt & " record?", _ Public Function MyDelete(strPrompt As String, strTable As String) Dim strSql As String Public Function SubForms(frm As Access.Form) As VBA.CollectionĪs a general rule to build say custom menu bars, or ribbons, you can write code that is “form” neutral like this: SetFocuspart as not necessary or any reason to for setting focus? Why is NewRecord a function? Doesn't return anything.ītw: I am working on a SubForms(frm)function, that returns a collection of all subforms.Ĭode: 'SubForms(frm As Access.Form) returns a collection of all subform references in frm You are passing the same form two times in your code, any reason? If Forms contains Command19 use Me. Your code Public Function FrmNewRecord(frm As Access.Form)įrmNewRecord(Forms!) ' mainformįrmNewRecord(Forms!!sfrmControl.Form) ' subform You can easy refer to the mainform with Set mfrm = frm.Parent Your function should have just one argument as it is sufficent to pass only the subforms reference if you need that form NewRecord(frm as Access.Form) (note the strong name!). To be honest, I don't use strong names either (except on database or recordset objects, as I got trapped there too, assuming DAO, using ADODB), but the Pros suggest that and now we know why! If you use NewRecordin Module òr Class it works too as there is no property with same name (I assume -)). If you use MyModulName.NewRecord(frm1,frm2)everything is fine. NewRecordis a forms property, so Invalid Use Of Propertymakes sense. You got trapped using an already in this context (the form) used identifier and not using a strong name (NameOfLibrary.NameOfFunction).






Unipaas subfurm function