Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Displaying SQL datetime value's date portion in a grid
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00782497
Message ID:
00785517
Views:
20
Sure. For this example, let's say you have a birth_date field in an employee SQL table, and you have a form with a text box bound to employee.birth_date in a VFP cursor/view. First, make sure that employee.birth_date field in the cursor is a datetime data type. Then, create a new form property called dBirth_Date with access and assign methods. Here is the access method...
local vDate, lcThisPropName, lcControlSource

lcThisPropName   = 'dBirth_Date'
lcControlSource  = 'employee.birth_date'


vDate       = &lcControlSource
if isnull(vDate) or empty(vDate)
	this.&lcThisPropName = ctod('  /  /    ')
else
	this.&lcThisPropName = ttod(vDate)
endif
RETURN THIS.&lcThisPropName
Here is the assign method...
lparameters vNewVal
local lcThisPropName, lcControlSource, lcFieldName, lcTableName, lni

lcThisPropName   = 'dBirth_Date'
lcControlSource  = 'employee.birth_date'


lni  = at('.', lcControlSource)
lcTableName  = left(lcControlSource, lni - 1)
lcFieldName  = substr(lcControlSource, lni + 1)
if empty(vNewVal)
	replace &lcFieldName  with .null. in &lcTableName
else
	replace &lcFieldName  with dtot(m.vNewVal) in &lcTableName
endif
THIS.&lcThisPropName = m.vNewVal
Finally, change the ControlSource property on the text box to "thisform.dbirth_date". That's all there is to it. Notice that I set values in the lcThisPropName and lcCountrolSource varables. This makes it easier to use copy/paste to other date related controls.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform