Issue with unbound Sub form VBA (1 Viewer)

paulcherianc

Registered User.
Local time
Today, 11:17
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:17
Joined
May 7, 2009
Messages
19,169
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
 

paulcherianc

Registered User.
Local time
Today, 11:17
Joined
Aug 15, 2013
Messages
86
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: 158

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:17
Joined
May 7, 2009
Messages
19,169
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.
 

paulcherianc

Registered User.
Local time
Today, 11:17
Joined
Aug 15, 2013
Messages
86
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"
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:17
Joined
May 7, 2009
Messages
19,169
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.
 

tranchemontaigne

Registered User.
Local time
Today, 11:17
Joined
Aug 12, 2008
Messages
203
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

Top Bottom