Link to home
Start Free TrialLog in
Avatar of julesuk71
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).
Avatar of AnswerTheMan
AnswerTheMan

1. set the focus to the control :
   nameOfControl.SetFocus
2. send the Ctrl+0 to the control :
   SendKeys ("^{0}"), True
Avatar of julesuk71

ASKER

We'll try your suggestion and get back to you for grading!
This is code we presently have on the Date Closed field:
Private Sub txtTaskDateClosed_lostfocus()
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???
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
Avatar of kbakst
kbakst

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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