Move to newrecord adds rec to db, but cant move to new rec 
Author Message
 Move to newrecord adds rec to db, but cant move to new rec

The users fill in text boxes of the form, then click a
commit button. I added the code below to make sure that if
the source code = 7 or 8 then the build date, serial #
must be blank. This part of the code works perfect.
However, the "else" code, all other source code values
must have a build date, serial # and when the code is
executed when there is a build date and a serial #, the
DoCmd.GoToRecord , , acNewRec gives me error 2105 You
can't go to the specified record. If you need the whole
application (856 kb) I can send it to you, otherwise here
is the culprit code. Thanks for you time in advance!
Mike
Private Sub new_record_button_Click()
On Error GoTo Err_new_record_button_Click
'mcr start
Dim strMsg As String
Dim strMsg2 As String
Dim strErrField As String
    DoCmd.GoToControl "source"
    'business rule: if source code = 7 or 8 then
build_date and seq must be
    'null or spaces.
    If source.Text = "7" Or source.Text = "8" Then
       DoCmd.GoToControl "Build_date"
       If IsNull(Build_date.Text) Or Build_date.Text = ""
Then
       Else
            strErrField = "Build Date"
            strMsg = "Field must be blank for '" &
strErrField _
                & "' when Source code = 7 or 8." & vbCrLf
& "Please correct " _
                & "this field now."
            If MsgBox(strMsg, vbQuestion) = vbOK Then
                   Exit Sub
            End If
       End If
       DoCmd.GoToControl "seq"
       If IsNull(Seq.Text) Or Seq.Text = "" Then
       Else
            strErrField = "Serial #"
            strMsg = "Field must be blank for '" &
strErrField _
                & "' when Source code = 7 or 8." & vbCrLf
& "Please correct " _
                & "this field now."
            If MsgBox(strMsg, vbQuestion) = vbOK Then
                   Exit Sub
            End If
       End If
    Else
       DoCmd.GoToControl "Build_date"
       If IsNull(Build_date.Text) Or Build_date.Text = ""
Then
            strErrField = "Build Date"
            strMsg2 = "Data must be entered for '" &
strErrField & "'." _
                & vbCrLf & "Please enter data for this
field now."
            If MsgBox(strMsg2, vbQuestion) = vbOK Then
                   Exit Sub
            End If
       End If
       DoCmd.GoToControl "seq"
       If IsNull(Seq.Text) Or Seq.Text = "" Then
            strErrField = "Serial #"
            strMsg2 = "Data must be entered for '" &
strErrField & "'." _
                & vbCrLf & "Please enter data for this
field now."
            If MsgBox(strMsg2, vbQuestion) = vbOK Then
                   Exit Sub
            End If
       End If
    End If
'mcr end
    DoCmd.GoToRecord , , acNewRec
    DoCmd.GoToControl "Clock"

Exit_new_record_button_Click:
    Exit Sub

Err_new_record_button_Click:
'    If Err = 2105 Then Resume Next

    MsgBox Err.Description
    MsgBox Err.Number

    Resume Exit_new_record_button_Click

End Sub
;



Sat, 19 Nov 2005 06:48:53 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. New Rec with previous Rec data

2. Perform a go to new rec w/ retaining some info from prev rec

3. New Rec with previous Rec data

4. New Rec with Data Based on Previous Rec's Data

5. Move to another rec event

6. changes to all records in one rec set based on position in another rec set

7. New record added to listbox, but won't load rec in form when selec

8. Problem with adding new rec with form containing a subform

9. Add new Rec's to a Sub frm when Allow Additions = False

10. Insert new rec, then pass new identity val back to Access97


 
Powered by phpBB® Forum Software © phpBB Group