A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Problems after enter press.



 
 
Thread Tools Display Modes
  #1  
Old May 4th, 2009, 04:44 AM posted to microsoft.public.access
ldiaz
external usenet poster
 
Posts: 201
Default Problems after enter press.


Hello all.
I have this code, but when I enter a value and press enter, the set focus
goes directly to first line of the records of the subform,

I think the problem is the setfocus event, but how can I solve this?
Thanks in advanced.
=============================
Private Sub DT_Min_AfterUpdate()
Me.Recalc

If ([Forms]![frm_Production_Report]![TSum]) 60 Then
MsgBox "You can't report a value greater that 60 Minutes!", vbCritical,
"Error, exceed value"
'Delete value
Me.DT_Min = "1"
'pass code
Me.DT_Code.SetFocus
'focus
Me.DT_Min.SetFocus

ElseIf IsNull(Me.DT_Min) Or Me.DT_Min 1 Then

MsgBox "Zero or Null value, select a value beetween 1 and 60", vbCritical,
"Zero or Null value error"
'Delete value
Me.DT_Min = "1"
'pass code
Me.DT_Code.SetFocus
'focus
Me.DT_Min.SetFocus


Else
Me.Comments.SetFocus
End If


End Sub
=============================

--
Lorenzo DÃ*az
Cad Technician
  #2  
Old May 4th, 2009, 01:27 PM posted to microsoft.public.access
BruceM[_4_]
external usenet poster
 
Posts: 558
Default Problems after enter press.

It is not clear what you are trying to do. What I see is that in the After
Update event of the control DT_Min you are checking the value in the TSum
field or control on another form (frm_Production_Report). If the current
form is frm_Production_Report you can just use the Me prefix: Me.TSum.

You say you are deleting the value, but then you set it to 1. After that
you set control to DT_Code, then to DT_Min.

If you need to validate the entry in a control, use the Before Update event,
which can be canceled. After Update may be too late for your needs.

Private Sub DT_Min_BeforeUpdate()

If Me.DT_Min 60 Then
MsgBox "60 maximum"
Cancel = True
End If

If this does not address the problem, describe what you hope to accomplish.
Include names of controls. I usually name the control something other than
the field name (e.g. txtDT_Min) to avoid confusion, both for myself and
Access, which can in some cases become addled when trying to deal with a
field and control that share the same name.


"ldiaz" wrote in message
...

Hello all.
I have this code, but when I enter a value and press enter, the set focus
goes directly to first line of the records of the subform,

I think the problem is the setfocus event, but how can I solve this?
Thanks in advanced.
=============================
Private Sub DT_Min_AfterUpdate()
Me.Recalc

If ([Forms]![frm_Production_Report]![TSum]) 60 Then
MsgBox "You can't report a value greater that 60 Minutes!", vbCritical,
"Error, exceed value"
'Delete value
Me.DT_Min = "1"
'pass code
Me.DT_Code.SetFocus
'focus
Me.DT_Min.SetFocus

ElseIf IsNull(Me.DT_Min) Or Me.DT_Min 1 Then

MsgBox "Zero or Null value, select a value beetween 1 and 60", vbCritical,
"Zero or Null value error"
'Delete value
Me.DT_Min = "1"
'pass code
Me.DT_Code.SetFocus
'focus
Me.DT_Min.SetFocus


Else
Me.Comments.SetFocus
End If


End Sub
=============================

--
Lorenzo Díaz
Cad Technician



  #3  
Old May 6th, 2009, 06:05 PM posted to microsoft.public.access
ldiaz
external usenet poster
 
Posts: 201
Default Problems after enter press.

it's now fixed, thanks

right now I have a similar problem.


how can I make this operation:
me.form.recalc

without lost the setfocus on the row?

Thanks
LD

--
Lorenzo DÃ*az
Cad Technician


"BruceM" wrote:

It is not clear what you are trying to do. What I see is that in the After
Update event of the control DT_Min you are checking the value in the TSum
field or control on another form (frm_Production_Report). If the current
form is frm_Production_Report you can just use the Me prefix: Me.TSum.

You say you are deleting the value, but then you set it to 1. After that
you set control to DT_Code, then to DT_Min.

If you need to validate the entry in a control, use the Before Update event,
which can be canceled. After Update may be too late for your needs.

Private Sub DT_Min_BeforeUpdate()

If Me.DT_Min 60 Then
MsgBox "60 maximum"
Cancel = True
End If

If this does not address the problem, describe what you hope to accomplish.
Include names of controls. I usually name the control something other than
the field name (e.g. txtDT_Min) to avoid confusion, both for myself and
Access, which can in some cases become addled when trying to deal with a
field and control that share the same name.


"ldiaz" wrote in message
...

Hello all.
I have this code, but when I enter a value and press enter, the set focus
goes directly to first line of the records of the subform,

I think the problem is the setfocus event, but how can I solve this?
Thanks in advanced.
=============================
Private Sub DT_Min_AfterUpdate()
Me.Recalc

If ([Forms]![frm_Production_Report]![TSum]) 60 Then
MsgBox "You can't report a value greater that 60 Minutes!", vbCritical,
"Error, exceed value"
'Delete value
Me.DT_Min = "1"
'pass code
Me.DT_Code.SetFocus
'focus
Me.DT_Min.SetFocus

ElseIf IsNull(Me.DT_Min) Or Me.DT_Min 1 Then

MsgBox "Zero or Null value, select a value beetween 1 and 60", vbCritical,
"Zero or Null value error"
'Delete value
Me.DT_Min = "1"
'pass code
Me.DT_Code.SetFocus
'focus
Me.DT_Min.SetFocus


Else
Me.Comments.SetFocus
End If


End Sub
=============================

--
Lorenzo DÃ*az
Cad Technician




  #4  
Old May 7th, 2009, 12:14 PM posted to microsoft.public.access
BruceM[_4_]
external usenet poster
 
Posts: 558
Default Problems after enter press.

I have not been able to duplicate the problem. How are you running the
code, and for what reason?

"ldiaz" wrote in message
news
it's now fixed, thanks

right now I have a similar problem.


how can I make this operation:
me.form.recalc

without lost the setfocus on the row?

Thanks
LD

--
Lorenzo Díaz
Cad Technician


"BruceM" wrote:

It is not clear what you are trying to do. What I see is that in the
After
Update event of the control DT_Min you are checking the value in the TSum
field or control on another form (frm_Production_Report). If the current
form is frm_Production_Report you can just use the Me prefix: Me.TSum.

You say you are deleting the value, but then you set it to 1. After that
you set control to DT_Code, then to DT_Min.

If you need to validate the entry in a control, use the Before Update
event,
which can be canceled. After Update may be too late for your needs.

Private Sub DT_Min_BeforeUpdate()

If Me.DT_Min 60 Then
MsgBox "60 maximum"
Cancel = True
End If

If this does not address the problem, describe what you hope to
accomplish.
Include names of controls. I usually name the control something other
than
the field name (e.g. txtDT_Min) to avoid confusion, both for myself and
Access, which can in some cases become addled when trying to deal with a
field and control that share the same name.


"ldiaz" wrote in message
...

Hello all.
I have this code, but when I enter a value and press enter, the set
focus
goes directly to first line of the records of the subform,

I think the problem is the setfocus event, but how can I solve this?
Thanks in advanced.
=============================
Private Sub DT_Min_AfterUpdate()
Me.Recalc

If ([Forms]![frm_Production_Report]![TSum]) 60 Then
MsgBox "You can't report a value greater that 60 Minutes!", vbCritical,
"Error, exceed value"
'Delete value
Me.DT_Min = "1"
'pass code
Me.DT_Code.SetFocus
'focus
Me.DT_Min.SetFocus

ElseIf IsNull(Me.DT_Min) Or Me.DT_Min 1 Then

MsgBox "Zero or Null value, select a value beetween 1 and 60",
vbCritical,
"Zero or Null value error"
'Delete value
Me.DT_Min = "1"
'pass code
Me.DT_Code.SetFocus
'focus
Me.DT_Min.SetFocus


Else
Me.Comments.SetFocus
End If


End Sub
=============================

--
Lorenzo Díaz
Cad Technician






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:21 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.