Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

After IsNull message, delete original entry

Status
Not open for further replies.

JSD

Technical User
Jan 18, 2002
189
US
Hello,

I am workin with a db that has a form and a subform. The subform has a couple of controls on it that have If IsNull functions, then msg box. The only problem is that when the user clicks ok after an IsNull msg, The bogus value is still there. In fact, once I set focus away and back to the control it puts the cursor at the berginning, so I can't use a sendkeys del or backspace or something. I was under the impression that an 'undo' would delete the original entry. Here is an example of what I'm doing after update of 'jobno' control:

IF IsNull(Me!jobno) Then
MsgBox "You must scan a job number."
Me.undo
Me!wc.SetFocus
Me!jobno.SetFocus
End If

I just need a way to del the original value, or highlight the entire original value so if user messes up all they have to worry about is entereing a new value. Any help is always appreciated.

THanks

Jeremy





 
JSD,
I'm not sure if this will help, but here is food for thought. Instead of the me.undo line of your code, what about inserting the following:

me.controlname=me.controlname.oldvalue
me.controlname.setfocus

I use this code following a yes/no message box in the onclick event of a command button. My code goes something like this:

dim response as string
If (something) then
response=MsgBox(prompt, vbYesNo, title)
If response=vbYes then
me.controlname=me.controlname.oldvalue
goto exit_sub
Else
goto exit_sub
end if
end if

Exit_sub:
Exit sub

At any rate, perhaps the .oldvalue will work for you. Good luck!
 
Hi JSD,

Where have you got your code? If you put it in the BeforeUpdate event or Exit event, you can use Cancel=True ..

Code:
Private Sub JobNo_Exit(Cancel As Integer)

If IsNull(Me.JobNo) Then
    MsgBox "You must scan a job number."
    Cancel = True
End If

End Sub

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top