Re: You can’t go to the specified record.

alicejwz

Registered User.
Local time
Today, 00:11
Joined
Jul 9, 2003
Messages
91
Re: You can’t go to the specified record.

Hi all,

I'm getting this error " You can’t go to the specified record" when I ran DoCmd.GoToRecord , , acNewRec. I haven't found any help w/ error above using acNewRec. Please help!

Here is how my form works:
when user enters a value in mfg field it finds the previous record in the table and populate some of the fields in the form. then user enters a quantity and click next. In cmdNext click it moves to a new record and then calls subroutine to populate the fields in new record. This works great when no change required in the populated field. But when one of the populated fields(ex material_lotnum) gets edit and clicking next the error occurs in DoCmd.GoToRecord , , acNewRec.

Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click
Dim frmstr As String, ret_val As Integer, bag_n As Integer
Dim get_prev_bag_info As New ADODB.Command, rs_get_prev_bag_info As New ADODB.Recordset
Dim rstblDeflash As New ADODB.Recordset

frmstr = "Deflash_scan_bags"
‘validate the fields on the form
ret_val = validate_sampling_data1(frmstr, Left(Me!msp_barcode.Value, 9), Right(Me!msp_barcode.Value, 3))
If ret_val = 1 Then

DoCmd.GoToRecord , , acNewRec
Some other code

Exit_Err_cmdNext_Click:
If rs_get_prev_bag_info.State = adStateOpen Then
rs_get_prev_bag_info.close
End If

Set get_prev_bag_info = Nothing
Exit Sub

Err_cmdNext_Click:
MsgBox err.Description
Resume Exit_Err_cmdNext_Click

End Sub

Private Sub material_lotnum_Change()
Dim mat_n_len As Integer
mat_n_len = 8
'Me!material_lotnum.Text = ""

If Len(Trim(Me!material_lotnum.Text)) = mat_n_len Then
''Me!insert_lotnum.SetFocus
Me!insert_lotnum.SetFocus
Debug.Print Me!insert_lotnum.Text

Call ck_criteria 'get updated bag #

If (Trim(Me!insert_lotnum.Text)) <> “” Then
Me!bag_quantity.SetFocus
End If
End If
End Sub

‘get the next bag #
Function ck_criteria()
Dim ck_last_bag As New ADODB.Command
Call load_const
With ck_last_bag
.ActiveConnection = CurrentProject.Connection
.CommandText = "spDeflash_ck_last_bag"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("@work_ord_num", adChar, adParamInput, work_ord_num_length, work_ord_num)
.Parameters.Append .CreateParameter("@work_ord_line_num", adChar, adParamInput, work_ord_line_num_length, work_ord_line_num)
.Parameters.Append .CreateParameter("@mat_lotn", adChar, adParamInput, 28, Me!material_lotnum.Value)
.Parameters.Append .CreateParameter("@insert_lotn", adChar, adParamInput, 28, Me!insert_lotnum.Value)
.Parameters.Append .CreateParameter("@mfg_dt", adDate, adParamInput, 8, Me!mfg_dt.Value)
.Parameters.Append .CreateParameter("@mfg", adDate, adParamOutput, 8)
.Parameters.Append .CreateParameter("@bag_n", adInteger, adParamOutput, 4)
.Execute , , adExecuteNoRecords
End With

Me!bag_num.Value = ck_last_bag.Parameters("@bag_n").Value

End Function

I could really use your help. Thank you.
 

Users who are viewing this thread

Back
Top Bottom