I run three insert queries to populate the tables in my db - code below. If I run through line by line using F8 then no problem, but if I let the code go at full speed sometimes (most of the time) the final statement fails. I reckon this is because of the relationships and trying to execute the statement before commitment is complete.
How should I correct myself on this? (I can get it working by using sleep(500) after the initial insert, but what if this wasn't long enough for some reason?)
How should I correct myself on this? (I can get it working by using sleep(500) after the initial insert, but what if this wasn't long enough for some reason?)
Code:
SQL = "INSERT INTO tbl_GroupType ([GroupType]) VALUES ('" & GT & "');"
CurrentDb.Execute SQL
SQL = "INSERT INTO tbl_GroupArea ([GroupArea]) VALUES ('" & GA & "');"
CurrentDb.Execute SQL
SQL = "INSERT INTO tbl_AssignedGroup ([GroupName],[Type],[Area]) VALUES ('" & GN & "','" & GT & "','" & GA & "');"
CurrentDb.Execute SQL