need help with code ...

totolkhan

Registered User.
Local time
Today, 09:49
Joined
May 23, 2005
Messages
30
hi guys
i wana put this code on exit event of a text box but if i don't enter any thing in that then press tab or enter it shows me the debug msgbox

Me.CODE.SetFocus
DoCmd.FindRecord codesearch, acEntire, , acSearchAll, , acCurrent
DoCmd.GoToRecord acActiveDataObject, , acGoTo, CurrentRecord
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

would u please help me fix it ?!
 
It's kind of hard to tell from the information you posted, but I would think a simple if statement would fix your problem:

Code:
If isnull(txtBoxName) Then
    'Post your code here
End If

The effect should be that when you exit the text box and have typed nothing in the field, nothing will happen.

If you want something to happen even if the text box is empty, then you are going to need to give more specifics as to what the error message is saying to you. Click debug and note which line of code is highlighted as well.
 
actuly it works but nothing happens if i innput information

i wana use this code for a text box that if something will input ,it have to find what i'm looking for but if not nothings happen .

can i use this code that i wrote in after update event ?!
 
Sorry, I had wrote the code backwards, so that it would only run when the field was empty. You need to put the keyword Not before the isnull function:

Code:
If Not isnull(txtboxName) Then
    'Post your code here
End If

Assuming your code does what you want it to, you can put your code in the after_update event, as long as it is put inside of the If statement above. It will then run anytime the field is updated, unless it is updated to a Null value.
 

Users who are viewing this thread

Back
Top Bottom