I have a schedule program written that will determine what days and hours a program will run. This information is stored in a simple table which just has a few columns: Day, OnTime, and OffTime. The user can edit the schedule by selecting the day from a combo box and using a Number Editing box. This does work but not the way I want it to. It does update the database when the user changes the data.
What I want to be able to do is when the user selects a day from the combo box, the NumberEditing boxes load with the values from the Database for that day. Here's where the problem is:
When the user changes the time in the NumberEditing boxes, the following procedure is called:
Private Sub CWNumEdit1_ValueChanged(Value
As Variant, PreviousValue As Variant, ByVal OutOfRange As Boolean)
Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\dates.mdb")
Set rs = db.OpenRecordset("Schedule")
While Not rs.EOF
rs.Edit
If rs!Day = cboDayEdit.Text Then
rs!ontime_1 = CWNumEdit1.Value
rs.Update
End If
rs.MoveNext
Wend
End Sub
Again, this does work well, however, when the user selects the day they want to edit from the combo box, and the combo box loads up with the values from the database like so:
While Not rs.EOF
rs.Edit
If rs!Day = cboDayEdit.Text Then
CWNumEdit1.Value = rs!ontime_1
CWNumEdit2.Value = rs!offtime_1
CWNumEdit3.Value = rs!ontime_2
CWNumEdit4.Value = rs!offtime_2
End If
rs.MoveNext
Wend
When this procedure is called, and the NumberEdit box is changed to the value in the database, it calls the CWNumEdit1_ValueChanged procedure again, because the value has changed!
How can I load up the values in those numberediting boxes without calling t
he CWNumEdit procedure?