J
JK
I’m going to repost this because I don’t think my last post was clear.
In Access03 I have a workorders database. I originally used the MS
Workorders Example database to start with. The layout is still much the same.
I have a form, “Workorders by Customer†that displays some customer
information with a continuous subform listing the workorders assigned to that
customer. On the form “Workorders by Customer†there is a View All button
that opens the “Workorders†form without a filter – on that same form; there
is an Add New button that opens the “Workorders†form in Data Entry mode.
Each field/record in the subform has a double-click event that opens the
“Workorders†form to a specific record.
That said; let me explain the “Workorders†form. There is another Add New
button. There is also a check box call FieldRepair. If the workorder is for
work performed by a technician off-site (in the field) this check box is
selected (selected by default.) If the work is done in-house, the user must
deselect the check box. When the check box is deselected, another filed
called DatePickedUp is enabled and cleared of its default value.
The DatePickedUp field has a default value set to #1/1/1900#. This is only
because I have a report that when run displays all work completed in-house
with equipment that has not been picked up by the customer yet. So, if
DateFinished is not null (the actual work is done) and the DatePickedUp field
is null then display the record in my report.
Someone helped me with the following code some time ago. If the check box
FieldRepair is selected on the Workorders form (which again – it is by
default), then DatePickedUp is disabled and the default value (#1/1/1900#) is
set to that field. If the check box FieldRepair is deselected, the
DatePickedUp field is enabled and the default value is cleared allowing the
user to enter a date when the equipment is actually picked up by the
customer.
The code that makes it work is posted below.
The check box FieldRepair has an after update event and an On Click Event.
And, the Workorders form has a Current Event which calls the
FieldRepair_Afterupdate Event. All code is posted below.
My problem, when I select either the Add New button on the Workorders by
Customer form OR the Add New button on the Workorders form and then attempt
to deselect the FieldRepair check box, it automatically creates a new record
and the check box never deselects. If I click the check box four times, I’ll
find four new workorders assigned to the customer. I don’t get it – and it’s
driving me nuts. No one is probably going to read this because it’s so long,
but I don’t know what else to do… ïŒ Please help… Thx….
‘==============================
Private Sub FieldRepair_AfterUpdate()
'Grey Date Pickedup Field if Checked (FieldRepair)
Dim bLock As Boolean
bLock = Nz(Me.FieldRepair, True)
Me.[DatePickedUp].Locked = bLock
If Me!FieldRepair = False Then
Forms!Workorders![DatePickedUp] = Null
Else
End If
End Sub
‘==============================
Private Sub FieldRepair_Click()
' Declare a variable to hold the current record's key.
Dim vMyControlValue As Variant
' Save the current record's key.
vMyControlValue = Me.WorkorderID
' Requery the form.
Me.Requery
' Find the record whose key we saved.
Me.Recordset.FindFirst "WorkorderID=" & vMyControlValue
' Auto insert 1/1/1900 into the DatePickedUp Field if (FieldRepair)is
checked...
If Me!FieldRepair = True Then
Forms!Workorders![DatePickedUp] = #1/1/1900#
Else
' If you need code to achieve your other alternative,
' put it here. If not, you can delete the "Else" statement.
End If
End Sub
‘==============================
In Access03 I have a workorders database. I originally used the MS
Workorders Example database to start with. The layout is still much the same.
I have a form, “Workorders by Customer†that displays some customer
information with a continuous subform listing the workorders assigned to that
customer. On the form “Workorders by Customer†there is a View All button
that opens the “Workorders†form without a filter – on that same form; there
is an Add New button that opens the “Workorders†form in Data Entry mode.
Each field/record in the subform has a double-click event that opens the
“Workorders†form to a specific record.
That said; let me explain the “Workorders†form. There is another Add New
button. There is also a check box call FieldRepair. If the workorder is for
work performed by a technician off-site (in the field) this check box is
selected (selected by default.) If the work is done in-house, the user must
deselect the check box. When the check box is deselected, another filed
called DatePickedUp is enabled and cleared of its default value.
The DatePickedUp field has a default value set to #1/1/1900#. This is only
because I have a report that when run displays all work completed in-house
with equipment that has not been picked up by the customer yet. So, if
DateFinished is not null (the actual work is done) and the DatePickedUp field
is null then display the record in my report.
Someone helped me with the following code some time ago. If the check box
FieldRepair is selected on the Workorders form (which again – it is by
default), then DatePickedUp is disabled and the default value (#1/1/1900#) is
set to that field. If the check box FieldRepair is deselected, the
DatePickedUp field is enabled and the default value is cleared allowing the
user to enter a date when the equipment is actually picked up by the
customer.
The code that makes it work is posted below.
The check box FieldRepair has an after update event and an On Click Event.
And, the Workorders form has a Current Event which calls the
FieldRepair_Afterupdate Event. All code is posted below.
My problem, when I select either the Add New button on the Workorders by
Customer form OR the Add New button on the Workorders form and then attempt
to deselect the FieldRepair check box, it automatically creates a new record
and the check box never deselects. If I click the check box four times, I’ll
find four new workorders assigned to the customer. I don’t get it – and it’s
driving me nuts. No one is probably going to read this because it’s so long,
but I don’t know what else to do… ïŒ Please help… Thx….
‘==============================
Private Sub FieldRepair_AfterUpdate()
'Grey Date Pickedup Field if Checked (FieldRepair)
Dim bLock As Boolean
bLock = Nz(Me.FieldRepair, True)
Me.[DatePickedUp].Locked = bLock
If Me!FieldRepair = False Then
Forms!Workorders![DatePickedUp] = Null
Else
End If
End Sub
‘==============================
Private Sub FieldRepair_Click()
' Declare a variable to hold the current record's key.
Dim vMyControlValue As Variant
' Save the current record's key.
vMyControlValue = Me.WorkorderID
' Requery the form.
Me.Requery
' Find the record whose key we saved.
Me.Recordset.FindFirst "WorkorderID=" & vMyControlValue
' Auto insert 1/1/1900 into the DatePickedUp Field if (FieldRepair)is
checked...
If Me!FieldRepair = True Then
Forms!Workorders![DatePickedUp] = #1/1/1900#
Else
' If you need code to achieve your other alternative,
' put it here. If not, you can delete the "Else" statement.
End If
End Sub
‘==============================