Solved

Not in List (goes to next record after update)

Posted on 2013-06-11
2
462 Views
Last Modified: 2013-06-11
When I apply the following code to not in list (bound form), the code does add new data to table and field but also moves to next record. How do I keep from moving to next record?

Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim Msg As String
Dim NewID As String
'On Error GoTo Err_Provider_NotInList

       ' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub

    ' Confirm that the user wants to add the new Sku.
Msg = "File Status" & space(1) & " '" & NewData & "' does not exist." & vbCr & vbCr
Msg = Msg & "Do you want to create status?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
        ' If the user chose not to add a Sku, set the Response
        ' argument to suppress an error message and undo changes.
Me.Undo
Response = acDataErrContinue
    Else
        ' If the user chose to add a new Sku, open a recordset
        ' using the tblSku table.
    Set conn = CurrentProject.AccessConnection
    Set rst = New ADODB.Recordset
    With rst
   .Open "SELECT * FROM TblUSHSFileStatus", conn, adOpenDynamic, adLockOptimistic
   .AddNew
   .Fields("Status").value = NewData
   .Fields("Lastupdate").value = Date
   .Fields("ModifyRecord").value = fOSUserName
  .Update
  ' .Requery
  .Close

MsgBox "File status has been updated"

Response = acDataErrAdded

End With

End If

'Exit_Provider_NotInList:
' '      Exit Sub
Err_Provider_NotInList:
       ' An unexpected error occurred, display the normal error message.
  '     MsgBox Err.Description
       ' Set the Response argument to suppress an error message and undo
       ' changes.
   '    Response = acDataErrContinue
0
Comment
Question by:jbakestull
2 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39239077
in the design view of the form, hit F4 to view the Property Sheet of the form

select the Other tab

in the Cycle property, set the value to current Record
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39239109
You have remarked out your exit and error processing code, why did you do that?

Aside from the exit/error processing code, I don't see anything here that would cause your main form to move to the next record after processing this code.

Are you sure there isn't something else going on here, after this code is processed?
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now