Issue with unbound Sub form VBA

paulcherianc

Registered User.
Local time
Today, 00:04
Joined
Aug 15, 2013
Messages
86
I am trying from the mainform to check whether the subform field is blank and take an action. But it doesn't work :confused: . Can anyone support!

Main Form = Proposal_1AABEmployee_MasteR_Tab
Subform (unbound) = Proposal_A-Master_Table subform
Combobox Control Name = Prop_Appraisal Type


Code:
If [Forms]![Proposal_1AABEmployee_MasteR_Tab]![Proposal_A-Master_Table subform]![Form]![Prop_Appraisal Type] = "" Then
MsgBox "Please select the type of Appraisal" 
End if
 
If [Forms]![Proposal_1AABEmployee_MasteR_Tab]![Proposal_A-Master_Table subform].[Form]![Prop_Appraisal Type] = "" Then
MsgBox "Please select the type of Appraisal"
End if
 
Arnel i am getting an error (Attached) with the above code. Could you please help.

Actually i have an unbound subform control and on event current its loading my subform.

unbound subform name :subformcontainer


:confused:
 

Attachments

  • Error1.JPG
    Error1.JPG
    19.2 KB · Views: 188
so you have 2 unbound subform?
try first to debug the load event of your subform's to find out which one is loading first.
or else use a timer event of the subform to check the value after all subforms/forms have been loaded.
 
Dear Arnel,

On form load event i have not mentioned any subforms. but the following:

Code:
Private Sub Form_Load()
Me.[SubFormContainer].Locked = True
End Sub

How ever on my tab control change i have different cases. Case 0 is :

Code:
Private Sub TabCtrl_Change()

     Select Case Me.TabCtrl.Value

Case 0
Me.SubFormContainer.SourceObject = "Proposal_A-Master_Table subform"
 
on the load event of your form/subform check first if the sourceobject is indeed "Proposal_A-Master_Table subform".
if it is, then carry the test to check if [Prop_Appraisal Type] is blank.
 
Perhaps the original issue is simply a matter of empty verses null...

I use the NZ function to fill empty or null values with a value, then check for the new value

Try

If ( nz([Forms]![Proposal_1AABEmployee_MasteR_Tab]![Proposal_A-Master_Table subform].[Form]![Prop_Appraisal Type].value,"missing") = "missing" ) Then

MsgBox "Please select the type of Appraisal"

' if you want the field populated, you might want to consider setting the cursor inside of the field using syntax like this
[Forms]![Proposal_1AABEmployee_MasteR_Tab]![Proposal_A-Master_Table subform].[Form]![Prop_Appraisal Type].setfocus

End if
 
Last edited:

Users who are viewing this thread

Back
Top Bottom