Script current date as a column header

2 posts / 0 new
Last post
ShadyP
Offline
Joined: 12/17/2020 - 17:15
Script current date as a column header

Hello, I am relatively new to IDEA scripting and have come to my first brick wall.  Hopefully someone here may know the answer. I am trying to script a self updating database to keep track of inventory audits.  My script runs in the following order:

  1. import product list  
  2. import audit report of quantity changes
  3. join these databases, resulting in 2 columns from product list + 1 column from quantity change report
  4. export joined database overwriting origianl product list
  5. rinse/repeat twice per month.

 
This works great, but in order to continuously run the script the quantity change column header needs to be consistant.  My plan to import that file with "current date" as the quantity header doesn't work as that date will keep changing.   Is there a way to take the joined database, append a new field containing the quantity changes, and have that new field's name be the system date at the time the script runs?  
if I can do that, this process will continually add a new dated column each time it runs.  any thoughts?

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi ShadyP,

Here is some code that adds on the current date to the field name, hopefully you can integrate this into your code.


Sub Main
	Call AppendField()	'Account Summary-Database.IMD
End Sub


' Append Field
Function AppendField
	sDate = "DATE_" & Date()

	'Exit Function
	Set db = Client.OpenDatabase("Account Summary-Database.IMD")
	Set task = db.TableManagement
	Set field = db.TableDef.NewField
	field.Name = sDate
	field.Description = "Appended field"
	field.Type = WI_VIRT_CHAR
	field.Equation = " """" "
	field.Length = 4
	task.AppendField field
	task.PerformTask
	Set task = Nothing
	Set db = Nothing
	Set field = Nothing
End Function