PDA

View Full Version : MS Access 2000 SQL Crap


That_Is_My_El_Camino
12-23-2006, 12:57 PM
Is there any way to do a shit-ton of INSERT queries with MS Access 2000, outside of real programming, without making a new/separate query for each of them?

I mean I want to do a couple hundred queries like:

INSERT INTO A (1, 2, 3, ...);
INSERT INTO A (2, 3, 4, ...);
INSERT INTO A (3, 4, 5, ...);
without having to either create a new, separate query for each INSERT or replacing the old INSERT with another INSERT, executing that INSERT, and replacing it with yet another new INSERT.

I could do it with Visual C++, but that's a lot of programming and bullshit for something that, I would think, should be so fuckin' simple. :(

AbecX
12-23-2006, 01:31 PM
what? Show me a bit of the data you want to input and the schema you want it inputed in as.

That_Is_My_El_Camino
12-23-2006, 01:48 PM
You've gotz a PM, y0.

bullitt54
12-27-2006, 03:47 PM
Since you know C++ this should be fairly simple.

Make a new Module, you can type any VB code you want in the and execute it. (It's actually VBA but there isn't a whole lot of difference)

For example to execute a query through simple code do this:

Dim strSQL as string
strSQL = "put your sql statement here"

CurrentProject.AccessConnection.Execute strSQL

Since you need to input a lot of info you can make a loop and just include some variables in your SQL statement. VBA is easy.


Dim k as integer
k=0

while k <= 100
CurrentProject.AccessConnection.Execute "INSERT INTO [tblName] {" & k & "};"
k=k+1
Wend


The quickest way to execute the code is just hit F5 while your cursor is inside the function. You could also through it in a macro and tell it to RunCode and choose the function you want it to execute.