How to Preventing from Lostfocus

  • Thread starter Thread starter Bauji
  • Start date Start date
B

Bauji

I am using following coding in text30_lostfocus, but I am unable to handle it. My condition is not working properly. What ever I enter in Text30, if it is null, it should give the mesagebox and return back to same textbox other wise go to next control

I tried in various following event, but not able to make it workable.
*------Lost Focus Event--------------------------------------------------------------------------------*
If Text41="" Then
MsgBox "The Please enter name"
Me.Text30 = 0
Me.Text30.setfocus
End If
*-----------------------------------------------------------------------------------------------------*

*------On Exit Event--------------------------------------------------------------------------------*
If Text41="" Then
MsgBox "The Please enter name"
Me.Text30 = 0
Docmd.CancelEvent
Me.Text30.setfocus
End If
*-----------------------------------------------------------------------------------------------------*

*------Before Update Event-----------------------------------------------------------------------------*
If Text41="" Then
MsgBox "The Please enter name"
Me.Text30 = 0
Docmd.CancelEvent
Me.Text30.setfocus
End If
*-----------------------------------------------------------------------------------------------------*

I dont know what is wrong I am doing here, Please help me. I am stuck here.
 
I am using following coding in text30_lostfocus, but I am unable to handle it. My
condition is not working properly. What ever I enter in Text30, if it is null, it
should give the mesagebox and return back to same textbox other wise go to next
control

I tried in various following event, but not able to make it workable.

Use the Exit event but set Cancel = True. The original control will then never lose
focus making a line to set the focus back to it unnecessary.
 
-----Original Message-----
Rick

Thanks for reply, but still it is not working.I tried following
-----------*
Private Sub Text30_Exit(Cancel As Integer)
If Int(Me.Text41) > Int(Me.Text38) Then
MsgBox "The Rejected Quantity has to be less than Received Quantity"
Me.Text41 = Int(Me.Text41) - Int(Me.Text30)
temp2 = 2
Me.Text30 = 0
Cancel = True
DoCmd.CancelEvent
Else
temp2 = 1
Me.Text41 = Int(Me.Text41) + Int(Me.Text30)
End If
End Sub
*-------------------------------------------------------- --*
I tried without docmd.cancelevent also, but it is also not working.

am unable to handle
it. My in Text30, if it is
null, it textbox other wise go to
next original control will then
never lose


.

Hi

I have done something similar to set the value of another
control. I have used the after update event

See example below

Private Sub Combo25_AfterUpdate()

If Not [Combo25].Value = "Current" Then
RaiseInvoice = True
Else
RaiseInvoice = False
End If

End Sub
Hope this helps

Paul
 
Rick

Thanks for reply, but still it is not working.I tried following

*-------------------------------------------------------------------*
Private Sub Text30_Exit(Cancel As Integer)
If Int(Me.Text41) > Int(Me.Text38) Then
MsgBox "The Rejected Quantity has to be less than Received Quantity"
Me.Text41 = Int(Me.Text41) - Int(Me.Text30)
temp2 = 2
Me.Text30 = 0
Cancel = True
DoCmd.CancelEvent
Else
temp2 = 1
Me.Text41 = Int(Me.Text41) + Int(Me.Text30)
End If
End Sub
*----------------------------------------------------------*
I tried without docmd.cancelevent also, but it is also not working.
 
Back
Top