Thank you ajetrumpet for your reply!
However your suggestion didn't work, it still gives the same error.
I'll just come clean and tell you that I got this piece of code from the internet, I do understand what it does no (after some searching and teaching myself on the internet) but couldn't have written it myself. Following your suggestion means deleting some of what I added. To end up with the original code I also removed the if statement that I added at the beginning of the code. So now I'm back at the code I got from the internet, with just the names of the tables etc different:
Code:
Public Function combine_groepen()
'turn off warning dialog
DoCmd.SetWarnings (False)
Dim rst As DAO.Recordset
Dim strCurrentContact As String
Set rst = CurrentDb.OpenRecordset("SELECT * FROM t_contact_categorie ORDER BY ContactID, GroepID")
strCurrentContact = vbNullString
'set groups back to null
strgroepen = vbNullString
Do
Do 'JUST A DO WILL BE FINE HERE
strgroepen = strgroepen & Nz(rst!GroepID, vbNullString) & ", "
strCurrentContact = rst!ContactID
rst.MoveNext
Loop Until rst!ContactID <> strCurrentContact 'OR JUST A LOOP HERE, NO EXTRA STUFF
strgroepen = Left(strgroepen, Len(strgroepen) - 2)
DoCmd.RunSQL "INSERT INTO t_contacts_inlinegrps ( ContactID, Groepen ) SELECT '" & strCurrentContact & "','" & strgroepen & "'"
'reset groups
strgroepen = vbNullString
Loop
rst.Close
Set rst = Nothing
'turn dialogs back on
DoCmd.SetWarnings (True)
End Function
The guy that wrote it admitted that this error was in there but said that 'this was easily fixable'. However he doesn't reply to questions on how to do this
So I'm still stuck. Any other suggestions?