Adding a string variable to the end of an INSERT query

ThisIsntMyRealName

Board Regular
Joined
May 23, 2009
Messages
69
Hey guys, I have this query below, my goal is to simply INSERT all of the fields from one record into another table, plus add one more string field at the end of that, what is the syntax for this?

Here is my query so far:

CurrentDb.Execute "INSERT INTO [Adage_IMMP_Combined_Join_Live_Exceptions] (Order_ID_Adage, Order_ID_IMMP, Join_Key, POH_Adage, POH_IMMP, Item_ID_Adage, Item_ID_IMMP, WHS_Code_Adage, WHS_Code_IMMP, Qty_Adage, Qty_IMMP, Lot_Adage, Lot_IMMP, User_Adage, User_IMMP, Trans_Date_Adage, Trans_Date_IMMP, Report_Date_Start, Report_Date_End, System_Adage, System_IMMP) " _
& "SELECT [Adage_IMMP_Join].Order_ID_Adage, [Adage_IMMP_Join].Order_ID_IMMP, [Adage_IMMP_Join].Join_Key, [Adage_IMMP_Join].POH_Adage, [Adage_IMMP_Join].POH_IMMP, [Adage_IMMP_Join].Item_ID_Adage , [Adage_IMMP_Join].Item_ID_IMMP, [Adage_IMMP_Join].WHS_Code_Adage , [Adage_IMMP_Join].WHS_Code_IMMP, [Adage_IMMP_Join].Qty_Adage, [Adage_IMMP_Join].Qty_IMMP, [Adage_IMMP_Join].Lot_Adage, [Adage_IMMP_Join].Lot_IMMP, [Adage_IMMP_Join].User_Adage, [Adage_IMMP_Join].User_IMMP, [Adage_IMMP_Join].Trans_Date_Adage, [Adage_IMMP_Join].Trans_Date_IMMP, [Adage_IMMP_Join].Report_Date_Start, [Adage_IMMP_Join].Report_Date_End, [Adage_IMMP_Join].System_Adage, [Adage_IMMP_Join].System_IMMP FROM [Adage_IMMP_Join]", dbFailOnError
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
'Your string here' AS NameOfField.
 
Upvote 0
Would it be possible to select * from table1 and then somehow combine another string from VBA with that select statement results? No idea how to format that!
 
Upvote 0
Sorry, but where does VBA come into this?

Did I miss something?
 
Upvote 0
Yes thats VBA, for example, I want add a variable like

dim strErrorString as String
strErrorString = "System 1 Lot Field is blank is blank."

I have a table mentioned above to insert the information into and I want to add this as the last field called 'Exception_Reason' which sits at the very end of the new table, otherwise the two tables have the same information, get it now?

I realize I could just assign all the variables to individual strings, but I'd rather not do that!
 
Upvote 0
If you mean you want to add a particular string for each record then you can't do it like this.

Is the string you want to add in another table linked to the table you are getting data from to append records?
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

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