Solved

Not in List (goes to next record after update)

Posted on 2013-06-11
2
505 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 48

Expert Comment

by:Dale Fye
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

623 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