julesuk71
asked on
Passing VB control to SQL7 db field
We have a form that contains date fields in a SQL table. The default for the field is null. However, once a date has been entered in the field, you cannot remove the date without then pressing Ctrl+0 to set the field back to Null. What commands could we use to send the Ctrl+0 to the field, and which area of the date field should we put it on (LostFocus, OnExit etc).
ASKER
We'll try your suggestion and get back to you for grading!
ASKER
This is code we presently have on the Date Closed field:
Private Sub txtTaskDateClosed_lostfocu s()
If txtTaskDateClosed = " " Then SendKeys ("^{0}"), True
End Sub
We have two screens - one is a summary screen, where you can select a particular record, then click a button which opens a Detail screen. If you remove an entry from the date field in the Summary screen, it stays "gone", which is perfect. However, if you remove the SAME date entry when you are in the Detail screen, when you return to the Summary screen, the date still appears in the field.
Any suggestions on this???
Private Sub txtTaskDateClosed_lostfocu
If txtTaskDateClosed = " " Then SendKeys ("^{0}"), True
End Sub
We have two screens - one is a summary screen, where you can select a particular record, then click a button which opens a Detail screen. If you remove an entry from the date field in the Summary screen, it stays "gone", which is perfect. However, if you remove the SAME date entry when you are in the Detail screen, when you return to the Summary screen, the date still appears in the field.
Any suggestions on this???
ASKER
As we have several date fields that need the option of removing the date, it seemed silly that we should have to put code on each field to reset it to null. There has to be a simpler and better solution than posting code on every date field that could be deleted.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, kbakst! That suggestion did actually work perfectly!!!
if you set the forms' textbox to be bound to the rs field (date) as a date then when there is no date given the null value is therefore passed to you data-source else a date must be given.
good luck,
Bachir
good luck,
Bachir
nameOfControl.SetFocus
2. send the Ctrl+0 to the control :
SendKeys ("^{0}"), True