set default on control in the OnLoad Event

abenitez77

Registered User.
Local time
Today, 13:05
Joined
Apr 29, 2010
Messages
141
I am dynamically trying to set a control default value. I have the code below in the On Load event of the form. I get an error msg that says "Run-time error '2467': The expression you entered refers to an object that is closed or doesn't exist." What I am doing wrong?

Forms(mainform)("Dyn_" & Trim(str(Project_ID)) & "_SubFrmTab03" & PT_Suffix & "_Approval").Controls("Groupid").DefaultValue = "=Forms!" & mainform & ".ClaimInfoGroupID"
 
Try something like this (not trying to write your code):
Code:
Dim strControl as string

strControl = "tab" & cstr(appID) & "_subFrm"
Me.controls(strControl).visible = true
 
I am now testing it on a button i put on the form. On click event for the button
Forms(mainform)("Dyn_" & T
rim(str(Project_ID)) & "_SubFrmTab03" & PT_Suffix & "_Approval").Controls("Groupid").DefaultValue = "=Forms!" & mainform & ".ClaimInfoGroupID"
basically something like this below
Forms!Dyn_6_ApprovalPP.Dyn_6_SubFrmTab03PP_Approval.Form.GroupID.DefaultValue = "=Forms!Dyn_6_ApprovalPP.Form.ClaimInfoGroupID"
is the syntax correct?
 
it's unreadable

is this what you want to see on the control?
=Forms!Dyn_6_ApprovalPP.Form.ClaimInfoGroupID
or do you want to see the value of it? in this case it should be:
.DefaultValue = Forms!Dyn_6_ApprovalPP.Form.ClaimInfoGroupID
 

Users who are viewing this thread

Back
Top Bottom