Validation problem with form on current event

delph

Registered User.
Local time
Today, 06:25
Joined
Oct 28, 2009
Messages
25
Hi all,

Hope someone can help. I am trying to write some code so that when a user goes into a subform only certain choices in a combo box, in that subform, display depending on whether another field in that subform has been populated.
I searched the forum & found this:

http://www.access-programmers.co.uk/forums/showthread.php?t=208653&highlight=validation

I thought this sounds ideal, however when I put my code in nothing happens:

Private Sub Form_Current()
If Me.ToBeDraftDte = "" Then
Me.cboStatus.RowSource = "Select * From tblStatus WHERE Status = 'To Be Drafted'"
Else
Me.cboStatus.RowSource = "Select * From tblStatus"
End If
End Sub

I thought the only option in the combo box would be "To Be Drafted" but I get all the options. Is it something to do with it being in a subform? Do I need to refresh?
Apologies if this is really simple, I'm only just starting with vba.
Many thanks for any replies.
 
If this is on the On Current event of the subform, the only change really would be this:

Code:
If Me.ToBeDraftDte = "" Then

to this:
Code:
If Len(Me.ToBeDraftDte & vbNullString) = 0 Then

that will check for nulls as well as empty strings
 
Hi Bob,

The code was on the On Current event of the subform.

I've changed my code to If Len(Me.ToBeDraftDte & vbNullString) = 0 Then
and it works just how I was wanting.

Thank you so much for your help.
 

Users who are viewing this thread

Back
Top Bottom