Hi,
i can not access my form field when i am trying to write code:
FormName is "QJuntion"Code:debug.print Forms(FormName).Controls(IDField)
Field is "PK_Customers"
Why this is not working ?
Best,
Jacek
Hi,
i can not access my form field when i am trying to write code:
FormName is "QJuntion"Code:debug.print Forms(FormName).Controls(IDField)
Field is "PK_Customers"
Why this is not working ?
Best,
Jacek
Ok problem is connected with active form.
First i have to refer to main form (active form) and next to subform, i am trying:
but this is not working...Code:strg = Screen.ActiveForm.Name Debug.Print Debug.Print Forms(strg)!Controls(FormName).Controls(IDField)
Best,
Jacek
Remove abundant "Debug.Print"
thank you, removed.
But still it is not working...
Jacek
Try (replace FormName, SubformName and ControlName)
NB! Maybe you need to convert the expression result to string using CStr() too.Code:Debug.Print Forms("FormName").SubformName.Form.ControlName
UseOR if control in subform thenCode:Forms!FormName.ControlName,
See this link http://allenbrowne.com/casu-04.htmlCode:Forms!FormName.SubFormControlName.Form.ControlName
debug.print FORM_frmName.field
Just add the red to the form name and away you go...
Thsnk you Guys,
i caught the issue.
My subform is not Copy Of Copy Of QJunction but "MainForm".
Code:
1. How can i use variable for MainForm and for TopoToJunction_ID field?Code:Debug.Print Forms(strg)!MainForm.Form.TopoToJunction_ID
StringSubformName ="MainForm"
--> this is not working.Code:Debug.Print Forms(strg)!StringSubformName.Form.Controls("TopoToJunction_ID")
2. How to take the name of form (MainForm) with VBA?
When i am try to do is: Me.Name --> result: "Copy Of Copy Of QJunction" and this throws an error.
Best Wishes,
Jacek
Are you trying to retrieve the newly added PK within the .AddNew proceedure?
you can do this with something like
rs.AddNew
...
...
...
NewID = rs.Fields("PkfieldName")
rs.update
Hi moke123
thank you. I have PK but i have to pass it to audit sub.
So i need the name of subform and reference to one field of it (with PK).
Please look at my above 2 questions.
Best,
Jacek
Dynamically referencing form/subform paths is difficult, as you have discovered.
Pass the PK by procedure argument or by setting a global variable or TempVars.
You have subform sitting on an UNBOUND Form1? Your 'Main' form is actually a subform? Why the UNBOUND form complication?
Why code to create new record?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I could do this but I want to audit all forms within access.Code:Pass the PK by procedure argument or by setting a global variable or TempVars.
So i have to pass proper name of form to my sub.
I can create global variable but i have to know how to refer to Name of form (like in picture above).
this is specially for synchronize 2 subforms like here:Code:You have subform sitting on an UNBOUND Form1? Your 'Main' form is actually a subform? Why the UNBOUND form complication?
http://www.fmsinc.com/microsoftacces...edsubforms.asp
so it has to be like that.
Code for create new records is connected with auditing forms.
Something like here:
https://www.fontstuff.com/access/acctut21.htm
Best,
Jacek
Image does not show two subforms side-by-side.
If you want to save the form name and the ID, both can be passed as procedure arguments.
Adapt code. I have never used Screen.ActiveForm.
I don't see a need to reference the form object directly.
Is it really important to document the form the edit took place in? Here is another audit trail example http://allenbrowne.com/AppAudit.html
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
By any chance, is the name of your subform control and your subform control sourceobject different?How to take the name of form (MainForm) with VBA?
When i am try to do is: Me.Name --> result: "Copy Of Copy Of QJunction" and this throws an error.
could the subform control be named Copy Of Copy Of QJunction and its source object be MainForm?