Autofill a set of records, based on template

I've made a flexible and easy copy+paste model, like excel, but I don't have to type anything. This works great, but I'd prefereably use something coded in VBA. This will do for now :)
Btw, did the database work, Paul?
 
To be honest, .rar is not a common format here, and I didn't want to download and install software to use it. I was hoping someone else would jump in. I'll throw together a sample that does it.
 
Here's a quick and dirty sample.
 

Attachments

That worked great, with a couple of adjustments.
Thanks alot for the help, brilliant! I also learned quite a few things too.
Code:
Private Sub cmdAdd_Click()
  Dim db            As DAO.Database
  Dim rs            As DAO.Recordset
  Dim x             As Long

  Set db = CurrentDb()

  Set rs = db.OpenRecordset("tblAnimeEpisode", dbOpenDynaset)

  For x = Me.txtStart To Me.txtEnd
    rs.AddNew
    rs!AnimID = Me.AnimeID
    rs!EpID = x
    rs.Update
  Next x

  MsgBox "Process complete"
  
  Set rs = Nothing
  Set db = Nothing
End Sub
This worked only because the fldEpisodeID is equal to fldEpisodeName, so EpID 10 has "Episode 10" as EpisodeName, and so forth..
But, what if it's shuffled? Like EpID 1 was "Episode 5" and so forth?
Is there any way to search the combobox for matches, and then use the result of that search as input? Something like: rs!EpID = LOOKUP("Episode " & x) ?

There is also one more thing; is it possible check if the record exists, and add only if it doesn't exist? like:
Code:
For x = 1 To Me.AnimeEpisodesTotal
   Exists?
    rs!AnimID = Me.AnimeID
    rs!EpID = x
   
If Exists? = True then
    rs.AddNew
    rs!AnimID = Me.AnimeID
    rs!EpID = x
   rs.Update
  
   Next x
The idea is to have one button for adding and updating the episode list, so if 20 episodes is added to the anime, and fldAnimeEpisodeTotal changes from 26 to 56, I could just click the button and the episode list would be updated.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom