Full Version: Tab control sub form
UtterAccess Forums > Microsoft® Access > Access Forms
kanamathareddy
I have a tab control on a form and have a subform named subfrmNPR on the tab control how do i reference the subform(subfrmNPR) from the main form
When I use this If [subfrmNPR].IDCards.Checked = True I get error message
can't find field '|' refrrred to in expression.
Any Help.
Thanks,
prasad
If [subfrmNPR].IDCards.Checked = True And IsNull(Trim([subfrmNPR].IDCardEstLoadDate)) Then
MsgBox "Please enter ID Card Est Load Date", vbOKOnly, "Required field"
[subfrmNPR].IDCardEstLoadDate.SetFocus
Exit Sub
End If
freakazeud
Hi,
it would be:
e!subfrmNPR.Form!IDCards
Furthermore...there is no checked property so just test for:
If Me!subfrmNPR.Form!IDCards = True ...
HTH
Good luck
Troulcortex
You can refer to the form object itself.
tep1:
Go to the target subform properties : Has Module -> yes
Now go to the main form VBA and you can now refer to the form like this:
If Form_subfrmNPR.IDCards.Checked
HTH,
Gabe
Troulcortex
Oli,
think Prasad is trying to refer to the control from outside the form, so he is going to need to use the object, right?
You are right, there is no "checked" property, I should have caught that...
Gabe
freakazeud
I'm reading the OPs request as him wanting to reference a control which is on a subform within a tab from the main form!
I guess we'll wait and see what the OP will clarify.
kanamathareddy
Using this Me!subfrmNPR.Form!IDCards I get another error message can't find field subfrmNPR
Troulcortex
Oh OK gotcha - sorry!
G
freakazeud
Is 'subfrmNPR' the name of the subform control? Can you attach a sample so we can better identify what you are trying to do and what exact syntax you need.
The above should have worked.
HTH
Good luck
kanamathareddy
"subfrmNPR" is the name of the actual subform and "ICards" is the name of one of the controls on the subform
Code on the main form is
If Me!subfrmNPR.Form!IDCards = True And IsNull(Trim(Me!subfrmNPR.Form!.IDCardEstLoadDate)) Then
MsgBox "Please enter ID Card Est Load Date", vbOKOnly, "Required field"
Me!subfrmNPR.Form!IDCards.IDCardEstLoadDate.SetFocus
Exit Sub
End If
I have a main form and a tab control on the main form and one of the tab controls I have a subform named "subfrmNPR" and when thes used clicks the main form save button I have the code to check to see if the user has a filed checked on the subform.
freakazeud
What's this:
sNull(Trim(Me!subfrmNPR.Form!.IDCardEstLoadDate))
There is a dot too much...and why are you using the trim function?
Then what is this:
Me!subfrmNPR.Form!IDCards.IDCardEstLoadDate.SetFocus
You can't reference to two controls in a row...either reference IDCards...or the other one, but not both! Like I said a sample as an attachment (under 500kb and zipped) might be helpful.
HTH
Good luck
kanamathareddy
Here is the code...
If Me!subfrmNPR.Form!IDCards = True And IsNull(Me!subfrmNPR.Form!.IDCardEstLoadDate)) Then
MsgBox "Please enter ID Card Est Load Date", vbOKOnly, "Required field"
Me!subfrmNPR.Form!IDCardEstLoadDate.SetFocus
Exit Sub
End If
I am trrying to make sure the user has IDCardEstLoadDate value when IDCrards is checked and setting the focus on IDCardEstLoadDate
The database is very big and cannot send the attachment
freakazeud
You still have a dot too much in there:
e!subfrmNPR.Form!.IDCardEstLoadDate
HTH
Good luck
kanamathareddy
If Me!subfrmNPR.Form!IDCards = True And IsNull(Me!subfrmNPR.Form!IDCardEstLoadDate) Then
MsgBox "Please enter ID Card Est Load Date", vbOKOnly, "Required field"
Me!subfrmNPR.Form!IDCardEstLoadDate.SetFocus
Exit Sub
End If
Still getting the same error message....
kanamathareddy
If Me!subfrmNPR.Form!IDCards = True And IsNull(Me!subfrmNPR.Form!IDCardEstLoadDate) Then
MsgBox "Please enter ID Card Est Load Date", vbOKOnly, "Required field"
Me!subfrmNPR.Form!IDCardEstLoadDate.SetFocus
Exit Sub
End If
Still getting the same error message....
freakazeud
Mhhh...looks right...try this then instead:
orms!Mainform!subfrmNPR.Form.IDCards
Change the name of the Mainform to your mainform name...also try to do it with one evaluation first rather then stringing them together...if one works by itself then there is a different problem then rather just the referencing.
HTH
Good luck
kanamathareddy
still getting the same error message..
If Forms!frmMain_Add_Update_Project!subfrmNPR.Form.IDCards = True Then
MsgBox "Please enter ID Card Est Load Date", vbOKOnly, "Required field"
Exit Sub
End If
freakazeud
And you can't attach a stripped down version of your db (maybe just import the one form into a new blank db)?
HTH
Good luck
kanamathareddy
I inherited the databse from someone else and it's all messed up.No coding standards and it is a piece of junk but I have to make changes....
jackb22
You say subfrmNPR is the name of the SUBFORM. If the name of the SUBFORM CONTROL is not the same, then you have to use the name of the SUBFORM CONTROL. Substitute the name of the SUBFORM CONTROL into the following:
If Me![SubformControlName].Form!IDCards = True And IsNull(Me![SubformControlName].Form!IDCardEstLoadDate)) Then
MsgBox "Please enter ID Card Est Load Date", vbOKOnly, "Required field"
Me![SubformControlName].Form!IDCardEstLoadDate.SetFocus
Exit Sub
End If
Jack
kanamathareddy
what do you mean by subformcontrol name?
jackb22
Open the Main form in design mode. Click on the Subform control. Look at the Name property for that control. That is the Subform Control Name.
ack
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.