Error 2427

AndyCompanyZ

Registered User.
Local time
Today, 20:19
Joined
Mar 24, 2011
Messages
223
I have this piece of code but is returning the error "You entered an expression that has no value":

Code:
Private Sub Frame76_AfterUpdate()
If Me.chkFinal = Yes And Me.ScheduledNumber < Me.CourseMInDel Then
    MsgBox "There are less than the minimum amount of delegates scheduled on this event.Please check before finalising"
ElseIf Me.chkFinal.Value = Yes And Me.ScheduledNumber > Me.CourseMaxDel Then
    MsgBox "There are too many delegates scheduled on this event. Please check before finalising"
End If
End Sub

Not sure why this happens. I wrote this more as pseudocode as I'm not sure of the correct syntax and am experimenting. Me.chkFinal is a tickbox inside a option group (I have only one option so far in it, I may add others later) . Can anyone point me to where I can solve this.
Thanks
 
Private Sub Frame76_AfterUpdate()
If (Me.chkFinal.Value = -1) And (Me.ScheduledNumber < Me.CourseMInDel) Then
MsgBox "There are less than the minimum amount of delegates scheduled on this event.Please check before finalising"

Else
If (Me.chkFinal.Value = -1 ) And (Me.ScheduledNumber > Me.CourseMaxDel) Then
MsgBox "There are too many delegates scheduled on this event. Please check before finalising"
End If
End Sub

It's not clear that Me.ScheduledNumber and Me.CourseMInDel are numeric???

Hope this gives some idea.
 
Thanks I'll try that and yes ScheduledNumber and CoursMIndel and CourseMaxDel are numeric will that make a difference.

I tried it but it still gives same error on first line
 
then print the values of the variables using debug.print , or inspect them in the debugger
 
Thanks I'll try that and yes ScheduledNumber and CoursMIndel and CourseMaxDel are numeric will that make a difference.

I tried it but it still gives same error on first line

It's look like that either Me.ScheduledNumber OR Me.CourseMInDel has a Null Value " " in your your field.

if so, then nz() function should solve this:

Code:
Private Sub Frame76_AfterUpdate()
If (Me.chkFinal.Value = -1) And nz((Me.ScheduledNumber < Me.CourseMInDel),0) Then
MsgBox "There are less than the minimum amount of delegates scheduled on this event.Please check before finalising"

Else
If (Me.chkFinal.Value = -1 ) And nz((Me.ScheduledNumber > Me.CourseMaxDel),0) Then
MsgBox "There are too many delegates scheduled on this event. Please check before finalising"
End If
End Sub
 
I tried the above code but still gives me same issue. There is no null value though.
Spike how do I inspect the values of the variables exactly (I'm a bit new to VBA). I have tried stepping through the code but it stops on line 1 and highlights it.
 
In the immediate window below type

?"*" & name_of_variable & "*"

or otherwise hold the cursor over the variable in question
 
or put
debug.print name_of_variable in your code , just before the stop, and it will be printed to your immedaite window
 
Ahh thanks I ran the cursor over and it says Me.ScheduledNumber=1 which is right
 
so? and the conclusion therefore is?
 
I imagine the conclusion is that there is a number there and that it should say that "there are less than the number etc" or am I thinking wrong.
I have now taken it out of the option group and have just put it on the form direct and now it doesn't error but neither does it do anything.
 
"You entered an expression that has no value"" -so there is something wrong with the expression.
Since the syntax is correct, the variables stink
You set a value of the first one directly so that's not it
Your second you just inspected, and it's ok
SO that leaves the third
 
"You entered an expression that has no value"" -so there is something wrong with the expression.
Since the syntax is correct, ...
SO that leaves the third

Spike as the OP is new and has less experience with the VBA,
It would be better to upload the sample db for analyzing it to go through and trap the bug.
 
#13 That is you opinion , with which I do not agree. I prefer to give people the means and methodology to find their own bugs. But that is a matter of taste, and you are free to debug OP's db.
 
Thanks for your help I got it going by taking it out of the option group and putting the same code behind the checkbox so it would appear to be something with it being in an option group.
 
you are right, but I disagree with you in certain situation if the needy is trapped with troubles and he/she searching for help rather to find the way to comes through...

any how, without knowing the exact cause of the problem nobody is perfect to solve it.
 
I agree it is better for me to try and find the bugs myself I will only learn that way so I think spike is OK to do it this way with me anyway.
 
#13 That is you opinion , with which I do not agree. I prefer to give people the means and methodology to find their own bugs. But that is a matter of taste, and you are free to debug OP's db.

{
"excellent"
}
 
you are right, but I disagree with you in certain situation if the needy is trapped with troubles and he/she searching for help rather to find the way to comes through...

any how, without knowing the exact cause of the problem nobody is perfect to solve it.
'
oh get over it. maybe you should have been a paramedic.
 

Users who are viewing this thread

Back
Top Bottom