Navigation: Advanced Topics (click to see list) > Working With Macros >
|Top Previous Next|
To give you an idea of how a macro might look, here's a simple example:
' This sample macro goes through all the records in the currently opened database
' For any record for which the person is "John Smith" and the project is "Jupiter Database"
' the macro will change the rate to $85.00 per hour
Dim App As Object
Set App = CreateObject("TimeLog.Application")
App.SetSQL("select start, person, project, rate, key from timerecords order by start")
NumRecords = App.GetNumRecords()
Dim Person As Variant
Dim Project As Variant
Dim NewRate As Variant
Dim ResultCode As Long
Person = ""
Project = ""
NewRate = 85.00
For i=1 To NumRecords
If i=1 Then
Person = App.GetFieldValue(1, ResultCode) ' Field 0 = Start, Field 1=Person, Field 2=Project
Project = App.GetFieldValue(2, ResultCode)
If Person = "John Smith" And Project="Jupiter Database" Then
MsgBox("Changing the Rate...")
Visit the Responsive Software web site http://www.ResponsiveSoftware.com for additional examples.