Skip to content

Instantly share code, notes, and snippets.

@janikvonrotz
Created June 10, 2013 14:51
Show Gist options
  • Save janikvonrotz/5749338 to your computer and use it in GitHub Desktop.
Save janikvonrotz/5749338 to your computer and use it in GitHub Desktop.
MSAccess: Create Foreign Key #VisualBasic #MSAccess
Public Sub VerweisErstellen(TableVerw As String, IDSource As String, IDSourceValue As Integer, IDDest As String, IDDestValue As Integer)
Dim db As DAO.Database
Set db = CurrentDb
'Delete of all Register data in link table
db.Execute "DELETE * FROM " & TableVerw & " WHERE " & IDSource & " = " & IDSourceValue, dbFailOnError
'Link the Register to the selected value
db.Execute "INSERT INTO " & TableVerw & " (" & IDSource & "," & IDDest & " ) VALUES(" & IDSourceValue & ", " & IDDestValue & ")"
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment