Results 1 to 4 of 4
  1. #1
    JoaoSousa is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2020
    Posts
    13

    Adding a new entry in a table to then be analysed

    Hello,



    To create an audit trail I'm creating a form to allow editions on an entry. This will create a new entry called AnalysisNumber = 2, 3, 4.... (It won't delete or change the previous one, just adds a new entry to it for the same case)
    I want to prevent my users from creating multiple blank entries. If the previous entry is not signed off on the Analysis form it won't create a new entry on the Edition form.

    A preview of the form
    Click image for larger version. 

Name:	data entry.PNG 
Views:	13 
Size:	8.2 KB 
ID:	42402
    I'm having trouble with the opening the recordset and asking the command to write the information down on the filtered query for the record.
    Private Sub Command9_Click()

    DoCmd.Requery


    If IsNull(Me.txtQCDateEntry) = True Then
    MsgBox ("Please sign entries of this case")
    Exit Sub
    End If


    If MsgBox("This will create a new entry, would you like to continue?", vbYesNo, "Edit an entry") = vbYes Then
    Dim Micro_Analysis As DAO.Recordset
    Set Micro_Analysis = CurrentDb.OpenRecordset("Micro_Analysis", dbOpenTable)
    Micro_Analysis.AddNew
    Micro_Analysis![Slide Label] = Me.btnEditSelect.Value

    The slide label will fill the information on a Look up to Slide Label to keep integrity of the relationship

    Micro_Analysis![AnalysisNumber] = Me.txtAnalysisNumber.Value

    The analysis number will be a ID-like field (the real ID is hidden) to say how many times this was analysed
    'DoCmd.OpenForm "EDITION DEVICE"
    End If



    End Sub


    Any idea for getting this code straight?...
    (I would also love to have the txtAnalysisNumber.Value do a SUM function, but I still haven't been able to get it to work yet... Any ideas on this would be helpful)


    Kind regards,
    Joao

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    you dont need any code (or recordsets),
    just run an update query: docmd.OPenquery "quUpdFld"

  3. #3
    JoaoSousa is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2020
    Posts
    13
    If I do an update qry doesn't it require a record to already exist?
    For audit reasons I can't alter what was written before so I need a new entry to be filled for the same sample that should be stated on the combo box that is present in the form

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Please try:
    Code:
    Private Sub Command9_Click()
    
    
    DoCmd.Requery
    
    
    
    
    If IsNull(Me.txtQCDateEntry) = True Then
    MsgBox ("Please sign entries of this case")
    Exit Sub
    End If
    
    
    
    
    If MsgBox("This will create a new entry, would you like to continue?", vbYesNo, "Edit an entry") = vbYes Then
    Dim Micro_Analysis As DAO.Recordset
    Set Micro_Analysis = CurrentDb.OpenRecordset("Micro_Analysis", dbOpenDynaset)
    Micro_Analysis.AddNew
    Micro_Analysis![Slide Label] = Me.btnEditSelect.Value
    
    
    The slide label will fill the information on a Look up to Slide Label to keep integrity of the relationship
    
    
    Micro_Analysis![AnalysisNumber] = Me.txtAnalysisNumber.Value
    Micro_Analysis.Update
    The analysis number will be a ID-like field (the real ID is hidden) to say how many times this was analysed
    'DoCmd.OpenForm "EDITION DEVICE"
    End If
    
    
    End Sub
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 10-28-2017, 08:28 AM
  2. Adding one entry to more than one table at once.
    By Tolpless_Mopar in forum Access
    Replies: 1
    Last Post: 10-15-2015, 10:31 AM
  3. Problems adding a new entry
    By octsim in forum Programming
    Replies: 1
    Last Post: 10-24-2013, 07:35 AM
  4. Replies: 4
    Last Post: 08-14-2012, 07:14 AM
  5. Adding colorfield to entry
    By carstenhdk in forum Forms
    Replies: 10
    Last Post: 05-10-2010, 05:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums