Results 1 to 7 of 7
  1. #1
    swavemeisterg is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    28

    Create multiple entries with same data


    I am creating an inventory database for logging test specimens, and sometimes we need to input a large amount of specimens that share all of the same attributes, but have different serial numbers. I have created a form for easy input of each specimen, but I would like to have an option to either duplicate the previous entry and edit one attribute, or create multiple entries.

    I am fairly new to access so please explain it in beginners terms. Thanks!

  2. #2
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    What i did in one of my databases is i placed checkboxes in front of the textfields.
    If the checkbox before a textfield is checked by the user then that value is copied to the new record.
    This way the user can choose wich fields to populate with the value of the last record, Preventing them having to type the value again.

    Code:
        If CheckBoxName = True Then
        Me.MyTextField = !MyTextField
        Else
        Me.MyTextField = ""
        End If
    Works fine for me (and my users)

    Ps : first make a button for creating a new record of course, then put above code below that (and edit the names of the checkbox and textField offcourse)

    Ill paste my whole code below

    Code:
    Private Sub knpNieuwRecord_recall_Click()
        DoCmd.GoToRecord , , acNewRec
        With Me.RecordsetClone
        .MoveLast
        
        If slvMerk = True Then
        Me.fldMerk = !Merk
        Else
        Me.fldMerk = ""
        End If
        
        If slvConfig = True Then
        Me.fldConfigNummer = !ConfiguratieNummer
        Else
        Me.fldConfigNummer = ""
        End If
        
        If slvDatumVastzetten = True Then
        Me.fldDatumUitvoer = !DatumUitvoer
        Else
        Me.fldDatumUitvoer = ""
        End If
        
        If slvChef = True Then
        Me.fldTekenbevoegdeChef = !TekenbevoegdeChef
        Else
        Me.fldTekenbevoegdeChef = ""
        End If
        
        If slvArtikel = True Then
        Me.fldArtikel = !Artikel
        Else
        Me.fldArtikel = ""
        End If
        
        If slvSerienummer = True Then
        Me.fldSerieNummer = !SerieNummer
        Else
        Me.fldSerieNummer = ""
        End If
        
        If slvAfgifteUitlening = True Then
        Me.kzlAfgifteUitlening = !AfgifteUitlening
        Else
        Me.kzlAfgifteUitlening = ""
        End If
        
        Me.fldPnummer = !Pnummer
        Me.fldAfdeling = !Afdeling
        Me.fldAchternaam = !Achternaam
        Me.fldLetters = !Letters
        Me.fldToestelNummer = !Toestelnummer
        
        
        If Me.Form.Dirty = True Then
        DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
        End If
        MsgBox "Uitvoerbon opgeslagen"
        
        Exit Sub
        End With
        End Sub
    Didnt have time to edit the names so you can understand them better, sorry

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    In your form, you can use the AfterUpdate event of the Control holding your data to set the DefaultValue for the Field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each New Record. So, for each Control to 'carry forward,'

    Code:
    Private Sub YourControlName_AfterUpdate()
       Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
    End Sub
    This code can be used for any Datatype Field.

    If you have a large number of these Controls to deal with, you can do the same thing like this:
    In Design View, select all Controls you want to "carry forward."
    Goto Properties - Other
    In the Tag Property enter CarryForward (without quotes)

    Now use this code:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim ctl As Control
    For Each ctl In Me.Controls
      If ctl.Tag = "CarryForward" Then
        ctl.DefaultValue = """" & ctl.Value & """"
      End If
    Next ctl
    End Sub
    Linq ;0)>

  4. #4
    swavemeisterg is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    28

    Sounds good but...

    JeroenMioch, the checkbox idea is perfect for what I want to do. The only problem is, I have no idea where to enter the code. I have a button which moves on to the next entry, but I don't know what to do past that. Do I go into the macro design tools? Because all that comes up there is a selection based coding window. I would much rather just code it myself. Thanks!

  5. #5
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Ok i hope i can talk you through it.
    You say "i have a button wich moves on to the next entry", i guess thats the button to go to a new record.
    In design view, right click that button.
    Now you see the buttons properties. Here you can alter the behaviour of the button and more important you can "tell" the button what to do if its clicked for example.
    To do this, you go to the buttons "on click" event. In your case the line next to the on click should read "event procedure" .
    Now click the three little dots at the end of that line. this will make you go to the VBA coding for that button.

    Before i continue i wanna make sure your with me so far. can you copy the code that you see and paste it to me so i can see what your button does.

    Also, make checkboxes and put them in front of the textfields you want to copy to the new record.
    After you did this, we will continue.

  6. #6
    swavemeisterg is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    28
    I figured it out! Thanks for the help I really appreciate it.

  7. #7
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Ok thats quick, But good to hear it works.
    If you have anymore questions then you know how to find us

    Greetings,

    Jeroen

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

Similar Threads

  1. Multiple Entries
    By alyon in forum Access
    Replies: 2
    Last Post: 05-15-2012, 07:45 AM
  2. Multiple extra entries
    By EDEd in forum Forms
    Replies: 1
    Last Post: 01-30-2011, 10:59 AM
  3. Multiple entries
    By danelliott in forum Access
    Replies: 3
    Last Post: 11-08-2010, 08:08 AM
  4. Multiple entries
    By Ziggy-R in forum Access
    Replies: 11
    Last Post: 10-03-2010, 07:42 PM
  5. Replies: 1
    Last Post: 09-21-2010, 09:49 AM

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
  •  
Other Forums: Microsoft Office Forums