Experts I need assistance with my program. I keep getting a cant go to specified record message when clicking on cmdNext. Im adding on to another persons code here and I cant figure out what Im doing wrong. Can you take a look at my code and see if theres anything obvious just popping out at you?
Option Compare Database
Private Sub cmdClose_Click()
If (Eval("[Forms]![frmData]![
ErrTypeCod
e] =' ' And [Forms]![frmData]![DataCom
ment] Is Null")) Then
DoCmd.CancelEvent
Beep
MsgBox "Comments required for all 'OTHER' type codes entered", vbCritical, "Comments Required"
DoCmd.GoToControl "[DataComment]"
Else: DoCmd.Close
End If
End Sub
Private Sub DescripCode_AfterUpdate()
Me.ErrTypeCode.RowSource = " SELECT distinct type, severity from tblTypeNew where [group] = " & Me.DescripCode
End Sub
Private Sub DescripCode_LostFocus()
Dim descpass As String
descpass = Me.DescripCode.Column(0)
Me.txtErrDesc.SetFocus
Me.txtErrDesc.Text = descpass
End Sub
Private Sub ErrTypeCode_AfterUpdate()
If (Eval("[Forms]![frmData]![
ErrTypeCod
e] =' ' And [Forms]![frmData]![DataCom
ment] Is Null")) Then
DoCmd.CancelEvent
Beep
MsgBox "Comments required for all 'OTHER' type codes entered", vbCritical, "Comments Required"
DoCmd.GoToControl "[DataComment]"
End If
End Sub
Private Sub ErrTypeCode_LostFocus()
Dim errcodepass As String
Dim errsevpass As String
errcodepass = Me.ErrTypeCode.Column(0)
errsevpass = Me.ErrTypeCode.Column(1)
Me.txtErrType.SetFocus
Me.txtErrType.Text = errcodepass
Me.txtErrSeverity.SetFocus
Me.txtErrSeverity.Text = errsevpass
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (Eval("[Forms]![frmData]![
ErrTypeCod
e]=' ' And [Forms]![frmData]![DataCom
ment] Is Null")) Then
DoCmd.CancelEvent
Beep
MsgBox "Comments required for all 'OTHER' type codes entered", vbCritical, "Comments Required"
DoCmd.GoToControl "[DataComment]"
End If
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToControl "AdjNum"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End Sub
Private Sub cmdRptEmail_Click()
On Error GoTo Err_cmdRptEmail_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim stDocName As String
stDocName = "rptFormEmail"
DoCmd.SendObject acSendReport, stDocName, acFormatRTF, , , , "QA Report", " Please reply when error is corrected"
Exit_cmdRptEmail_Click:
Exit Sub
Err_cmdRptEmail_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdRptEmail_Click
End Sub
Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click
DoCmd.GoToRecord , , acNewRec
Exit_cmdNext_Click:
Exit Sub
Err_cmdNext_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdNext_Click
End Sub
Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim stDocName As String
stDocName = "rptFormEmail"
DoCmd.OpenReport stDocName, acViewPreview
DoCmd.PrintOut acPages, 1, 1, , 2
DoCmd.Close acReport, stDocName
Exit_cmdPrint_Click:
Exit Sub
Err_cmdPrint_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdPrint_Click
End Sub
Start Free Trial