UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Field Validation check on a continuous sub form    
 
   
tmac31216
post Sep 11 2007, 09:54 AM
Post #1

UtterAccess Enthusiast
Posts: 51



I have this subform that is a continuous form which contains a combobox. Im trying to create a field validation for that combobox so that if its null, a warning box pops up and does not allow the user to close the main form unless a value is selected. The code I have below doesn't seem to work. I can still close the form when the combobox is null. Can someone please tell me what im doing wrong. Thanks

If IsNull(Me.JobTraderSubform_sfrm.Form.JobTraTraderNumber) Or _ Me.JobTraderSubform_sfrm.Form.JobTraTraderNumber = "" Then
MsgBox "Warning: You need to select a Trader.", vbOKOnly, "Warning"
Me.JobTraderSubform_sfrm.JobTraTraderNumber.SetFocus
Exit Sub
End If
Go to the top of the page
 
+
theDBguy
post Sep 11 2007, 10:06 AM
Post #2

Access Wiki and Forums Moderator
Posts: 48,068
From: SoCal, USA



Where do you have this code? You might have to put it in both the AfterUpdate event of the control and the BeforeUpdate event of the form. HTH.
Go to the top of the page
 
+
tmac31216
post Sep 11 2007, 10:08 AM
Post #3

UtterAccess Enthusiast
Posts: 51



I have it on the before update event on the subform. I'll try it on the both afterupdate and beforeupdate on the main form. thanks!
Go to the top of the page
 
+
tmac31216
post Sep 11 2007, 10:18 AM
Post #4

UtterAccess Enthusiast
Posts: 51



I'm not sure if I'm doing this correctly. I added the code to the AfterUpdate event on the combobox and to the BeforeUpdate on main form, but I get an Compile Error: Method or data member not found. for the BeforeUpdate event and highlighted the JobTraderSubform_sfrm.
Go to the top of the page
 
+
theDBguy
post Sep 11 2007, 10:31 AM
Post #5

Access Wiki and Forums Moderator
Posts: 48,068
From: SoCal, USA



Sorry, didn't know that you had a subform. The error is caused by improper reference to the control in the subform from the main form. See this article for more information. HTH.
Go to the top of the page
 
+
tmac31216
post Sep 11 2007, 10:48 AM
Post #6

UtterAccess Enthusiast
Posts: 51



Nevermind.....I got it to work.
Go to the top of the page
 
+
theDBguy
post Sep 11 2007, 11:49 AM
Post #7

Access Wiki and Forums Moderator
Posts: 48,068
From: SoCal, USA



Glad to hear that. Good luck with your project.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 24th May 2013 - 10:07 AM