String problem from last week

D

DavidW

I have got something I cannot get around.
I have used the if IsNull and the If Nz expression to stop a code from
executing if a textbox is empty.
Every expression I hvae entered I get the following error
"You have entered an expression that has no value!"
Below is a sample of my code that is in the "on current" event.
Any help is greatly appreciated

'checks for empy Textbox
If Nz([Forms]![onroaduse].Text33, "") = "" Then
[Forms]![onroaduse].on2!Text58.Visible = False
[Forms]![onroaduse].on2!Text60.Visible = False
'ends sub if textbox is empty
Exit Sub
End If
'find a duplicated record
If [Forms]![onroaduse].Text33 = [Forms]!onroaduse].Unit Then
DoCmd.Close acForm, ("reminder")
DoCmd.OpenForm ("verror")
End If
End Sub

[Forms]![onroaduse].Text33 has the default value from a second subform(2nd
subform is linked by unit/vehicle, and by date to the main form) that
references a query to search for existing records. The first subform is for
data entry only.
 
H

Howard Brody

Try:

If IsNull([txtTextBox]) Or [txtTextBox] = "" Then
Exit Sub
End If

It always works for me, although I don't think I've ever
used it in the OnCurrent event.

Hope this helps!

Howard Brody
 
D

DavidW

Finally Fiqured Out What to do
Using an Error Handler resolved my issue
Dont know why I didnt fiqure this out last week
Thank you al for responding to my problem
Excuse my redneck terminolagy!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top