charles
|
| Posted: 08/17/2005, 6:18 AM |
|
Hi,
I have a table of accounting periods with the following fields
period_id
period_description
date_from
date_to
I know how to write the query that can select the period based on the currentdate....ie
select period_id from period
where getdate() between period.date_from and period.date_to
My question is how do i make a listbox based on the period table default to the value of this database expression.
Regards,
charles
|
|
|
 |
Edd
Posts: 547
|
| Posted: 08/20/2005, 9:26 PM |
|
In the default value of the Listbox put in the name of a function, eg. GetCurrentPeriod()
Then in the Event coding, outside ALL other functions created the function,
function GetCurrentPeriod()
GetCurrentPeriod = CCDlookup("period_id", "accounting_periods","getdate() between date_from and date_to, DBNameodDB)
End function
Issues that you MIGHT encounter,
1. The value getdate is a DATETIME, therefore your to date must be populated with a TIME expiring at 11:59:59
2. The DBNameodDB may not be active, therefore instantiate the database class, eg.
function GetCurrentPeriod()
Dim DBConn
Set DBConn = new clsDBNameodDB
DBCOnn.Open
GetCurrentPeriod = CCDlookup("period_id", "accounting_periods","getdate() between date_from and date_to, DBConn)
DBConn.Close
Set DBConn = Nothing
end function
Hope than helps
Edd
_________________
Accepting and instigating change are life's challenges.
http://www.syntech.com.au |
 |
 |
|