Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Location
    Gatineau, Quebec Canada
    Posts
    147
    Provided Answers: 1

    Unanswered: Add New Record Problem

    Very strange. I use the following to switch between forms involving the same record:

    Private Sub cmdTransact_Click()

    Dim stLink As String
    stLink = "id=" & txtID.Value
    DoCmd.OpenForm "frmEvoTransact", , , stLink
    DoCmd.Close acForm, "frmEvoMain"
    End Sub

    This is reliable, and works well for existing records. The index number for a record is retained in a hidden field on the form (txtID). However, when I create a new record, it does not work at all EVEN THOUGH the value of txtID is set to a new ID number as the new record is created. It usually accesses the record called before the new record. I have tried using requery. No luck. I have to return to a central form, and recall the newly created record. Then all is fine. Must be a common problem, but I am not sure how to even do a search on it.


    Regards

    J. Smith
    Aylmer, Quebec

  2. #2
    Join Date
    Mar 2009
    Location
    Gatineau, Quebec Canada
    Posts
    147
    Provided Answers: 1

    Adding New Record Solved

    Should have looked harder. The solution is simple:

    Should lines should be:

    if me.dirty = true then
    me.dirty = false
    end if

    You have to force the save before doing anything else!

    John S
    Aylmer, Quebec

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    That correct, the Record doesn't exist until it's Saved.

    You probably also need to include a check to insure that the txtID Control has actually been populated before going to the second Form. Something like this will do it:
    Code:
     If Nz(Me.txtID, "") = "" Then
      MsgBox "YOU Must Enter an ID Number Before going to the EvoTransact Form!"
      txtID.SetFocus
     End If
    Also, since you're talking about a New Record, does a Record with the same ID already exist in frmEvoTransact? If not, how are handling that?

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Mar 2009
    Location
    Gatineau, Quebec Canada
    Posts
    147
    Provided Answers: 1
    Hi,

    The ID is an auto-number, a primary key and protected from prying fingers! On the forms its mostly idiot-proof, and stored in an invisible textbox. Should have remembered the "me.dirty" thing, but clean forgot (a danger of getting old). Thanks for your input.

    Regards


    John S

Tags for this Thread

Posting Permissions

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