Solved

Not in List (goes to next record after update)

Posted on 2013-06-11
2
476 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dynamically Reorder List Box 4 34
Combobox row source 2 19
deduplicating based on criteria 2 19
is Microsoft Access going to Die? 9 41
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

815 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

13 Experts available now in Live!

Get 1:1 Help Now