Results 1 to 3 of 3

Thread: Edit Add / Edit in Progress

  1. #1

    Thread Starter
    Lively Member The_Game's Avatar
    Join Date
    Apr 2006
    Posts
    115

    Edit Add / Edit in Progress

    I am having some trouble get the functionality of one of my buttons working properly.


    When i click the ok button, i need it to search an Access DB to see if the record exists. If the record exists i want to pop up a message box asking if you want to edit the record or not. If the response is no then i want to have them re-enter the information into the text fields, but if they answer yes that they want to edit it, i want to populate the data from the access DB onto the screen.

    I have that working, but my problem is that if they answer yes that they want to edit the information. I then populate the screen, but after they finish their editing, they click OK and get the same question asked.


    I am redoing an old form that used data controls, the code that was used before to accomplish what i need goes like this:

    VB Code:
    1. Private Sub cmdOK_Click()
    2.    ' Purpose:  Calls validation routines and writes the record to the database.
    3.    On Error GoTo cmdOK_ClickHandler
    4.    If ValPrimaryFields() Then
    5.       If datBatchHeader.EditMode = dbEditAdd Then
    6.          AddRecord
    7.       ElseIf datBatchHeader.EditMode = dbEditInProgress Then
    8.          If ValSecondaryFields() Then
    9.             WriteHeaderRecord
    10.          End If
    11.       End If
    12.    End If
    13.    Exit Sub
    14. cmdOK_ClickHandler:
    15.    HandleRunTimeError
    16. End Sub


    I am using Select's instead of the data control.


    Basically what i need is a way to ask if they want to edit once and if they answer yes, then the next time they hit OK, then should be proceeded to the next form and not asked the same question again


    Thanks for the help in advance

  2. #2

    Thread Starter
    Lively Member The_Game's Avatar
    Join Date
    Apr 2006
    Posts
    115

    Re: Edit Add / Edit in Progress

    I've been trying this:

    VB Code:
    1. If ValPrimaryFields() Then
    2.          If prvRsBatchHeader.EditMode = adEditAdd Then
    3.             AddRecord
    4.         ElseIf prvRsBatchHeader.EditMode = adEditInProgress Then
    5.             If ValSecondaryFields() Then
    6.                 WriteHeaderRecord
    7.             End If
    8.         End If
    9.     End If

    But it keeps giving me errors either way.

    One error says that this operation is not allowed when the object is open and when i close it, is says that this operation is not allowed when the object is closed.

  3. #3

    Thread Starter
    Lively Member The_Game's Avatar
    Join Date
    Apr 2006
    Posts
    115

    Re: Edit Add / Edit in Progress

    My problem is that the only value i can get for my recordset.editmode is a value of 0. Saying that i am doing nothing, but i am editing and adding data to the form.


    Does anyone know how do you set it up so that it works properly???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width