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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|