REALLY complex macro (1 Viewer)

Matizo

Registered User.
Local time
Yesterday, 17:22
Joined
Oct 12, 2006
Messages
83
Hi every1,

I have to create a macro to automate some procedures. I know some bits of it but sometimes I'm just confused.

The macro should:

1. run query (the query will create table tblDatesDifferences)
2. open table tblDatesDifferences
3. add new column
4. rename column for EndDate
5. change the data type for DATE/ TIME
6. delete the vary first record.
7. save changes
8. open table tblWorks
9. copy all data from column EndDate
10. open tblDatesDifferences
11. past data to column EndDate
12. delete vary last record
13. save changes
14. open report (which is based on the qNumberOfDaysBetweenWorks)

and after the report is printed or closed
15. delete table tblDatesDifferences

I tried to do it but I stacked on the renaming the column.

Thanks in advance!
 

Matizo

Registered User.
Local time
Yesterday, 17:22
Joined
Oct 12, 2006
Messages
83
I have the following code to rename my column..

Public Sub ChangeFieldName(tblDatesDifferences As String, Field1 As String, EndDate As String)
Dim db As DAO.Database, tdf As DAO.TableDef

Set db = CurrentDb
Set tdf = db.TableDefs(tblDatesDifference)

tdf(Field1).Name = EndDate

Set tdf = Nothing
Set db = Nothing
End Sub

but How can I execute this code??

Now I’ve got macro that looks like that:

1. SetWarnings = No
2. open query = qDateDifferenceBetweenWorks_CreateTable
3. open table = tblDatesDifferences
4. run command = InsertTableColumn
5. AND NOW I WANT TO RUN THE CODE ABOVE…

Thanks!
Matt
 

Moniker

VBA Pro
Local time
Yesterday, 19:22
Joined
Dec 21, 2006
Messages
1,567
Functionalize the code you have written and use RunCode from a Macro.

Before you ask how to do that, open any macro you have, type RunCode in as your Action, and look at the bottom in blue text for directions on how to do that.
 

Matizo

Registered User.
Local time
Yesterday, 17:22
Joined
Oct 12, 2006
Messages
83
I have module with this code:

Public Function ChangeFieldName(tblDatesDifferences As String, Field1 As String, EndDate As String)
Dim db As DAO.Database, tdf As DAO.TableDef

Set db = CurrentDb
Set tdf = db.TableDefs(tblDatesDifference)

tdf(Field1).Name = EndDate

Set tdf = Nothing
Set db = Nothing
End Function


and macro with RunCode action. But how should looks like the expresion to run this code?

Thanks,
 

Users who are viewing this thread

Top Bottom