error 3008 using INSERT INTO by VBA

Giobbe02

New Member
Joined
Oct 21, 2012
Messages
22
hello,

I have a problem with INSERT INTO....my form is connected to a Table "Cod" which has 2 fields: 'Cod' and 'Option', through my form I want to insert as many records as many options I have:
Example: cod: 4333333349 option: banana option:apple

CodOption
4333333349banana
4333333349apple

<tbody>
</tbody>

when I try to do it ACCESS says to me Error '3008': the table is already open with exclusive access from an other user....

my code:

Private Sub insert_rec_Cod()


CurrentDb.Execute "INSERT INTO Cod" _
& "([Cod], [OPT]) VALUES " _
& "(" & 4444444 & ", " & 4 & ");"


End Sub





Anyone knows a way to solve it?

thanks
cheers
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
If the form is bound to that table, don't try to run an INSERT statement at the same time; the form has locked the table.
Why aren't you just using the form for data entry? When you enter the values and go to a new record, it should just be saved to the table. Alternatively, you can have your data in another table (tblTemp), close the form and use something like this:

INSERT INTO Cod ([Cod],[Option])
SELECT Cod, Option FROM tblTemp

Denis
 
Upvote 0

Forum statistics

Threads
1,203,140
Messages
6,053,727
Members
444,681
Latest member
Nadzri Hassan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top