J
JK
I have a check box (access03) on a workorders form. I also have a date field
called DatePickedUp. If the work being done is done in the field, I have no
use for this field. So, I have a check box and if the check box is selected,
it disables the DatePickedUp field and automatically insers 1/1/1900 into
that field.
The code I pasted below works perfectly if it's an existing record. If
however, I'm creating a new record and I uncheck the FieldRepair check box to
specify the work being done is being done in-house, the form automatically
creates a new record. If I click the FieldReport check box five times, I'll
find five newly created records applied to that specific customer.
I also have a problem when deleting a record from this form. When I try to
delete a record, the form goes blank - all fields dissapear rather than
goinging to the next existing record or onto a new record. I have the form's
control source set directly to the workorders table.
Any advice would be great. -- 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
'Me.cmdDatePickedUp.Enabled = True
Else
'Me.cmdDatePickedUp.Enabled = False
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
Form_Current
Call FieldRepair_AfterUpdate
called DatePickedUp. If the work being done is done in the field, I have no
use for this field. So, I have a check box and if the check box is selected,
it disables the DatePickedUp field and automatically insers 1/1/1900 into
that field.
The code I pasted below works perfectly if it's an existing record. If
however, I'm creating a new record and I uncheck the FieldRepair check box to
specify the work being done is being done in-house, the form automatically
creates a new record. If I click the FieldReport check box five times, I'll
find five newly created records applied to that specific customer.
I also have a problem when deleting a record from this form. When I try to
delete a record, the form goes blank - all fields dissapear rather than
goinging to the next existing record or onto a new record. I have the form's
control source set directly to the workorders table.
Any advice would be great. -- 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
'Me.cmdDatePickedUp.Enabled = True
Else
'Me.cmdDatePickedUp.Enabled = False
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
Form_Current
Call FieldRepair_AfterUpdate