ChronicFear
Registered User.
- Local time
- Today, 02:28
- Joined
- Oct 18, 2007
- Messages
- 66
Hello,
I have a form where people enter information on a new work order. Among other things, they must enter the status of the order (open, closed, dead, more info requested), the date the order was received, and the date the order was completed/dead if applicable.
I'm trying to write a routine that makes sure the correct date fields are filled out based off the status that is selected. So if the status is "closed" or "dead", access wont save the record unless there is both a received date and a completed date, but it would not require a completion date if the status is "open" or "more info pending".
My problem is that this works fine for everything except "closed". If the user changes the status to "closed" then access appears to get stuck in a loop and seizes up.
You'll notice that this code contains no select case despite the title - it did originally, but when that froze I tried converting it to If-Then in hopes of resolution. No dice.
Your help is greatly appreciated!
Thanks,
CF
I have a form where people enter information on a new work order. Among other things, they must enter the status of the order (open, closed, dead, more info requested), the date the order was received, and the date the order was completed/dead if applicable.
I'm trying to write a routine that makes sure the correct date fields are filled out based off the status that is selected. So if the status is "closed" or "dead", access wont save the record unless there is both a received date and a completed date, but it would not require a completion date if the status is "open" or "more info pending".
My problem is that this works fine for everything except "closed". If the user changes the status to "closed" then access appears to get stuck in a loop and seizes up.
You'll notice that this code contains no select case despite the title - it did originally, but when that froze I tried converting it to If-Then in hopes of resolution. No dice.
Your help is greatly appreciated!
Thanks,
CF
Code:
Dim X As Integer
If Me.Status = "Open" Then
If Not IsNull([DateCompleted]) Then
X = MsgBox("A completion date has already been entered for this transaction. If this entry has been made in error and you would like to reopen this transaction, please select 'OK'. If you are processing a new transaction, please select 'Cancel' and create a new transaction.", vbOKCancel, vbInformation)
If X = vbOK Then
Me.DateCompleted.Value = ""
Me.CompletionTime.Value = ""
End If
End If
End If
If Me.Status = "Closed" Then
If IsNull([DateCompleted]) Then
Me.DateCompleted.Value = Date
BusinessDays DateReceived, DateCompleted
End If
End If
If Me.Status = "More Info Requested" Then
If Not IsNull([DateCompleted]) Then
X = MsgBox("A completion date has already been entered for this transaction. If this entry has been made in error and you would like to reopen this transaction, please select 'OK'. If you are processing a new transaction, please select 'Cancel' and create a new transaction.", vbOKCancel + vbInformation)
If X = vbOK Then
Me.DateCompleted.Value = ""
Me.CompletionTime.Value = ""
End If
End If
End If
If Me.Status = "Dead" Then
If IsNull([DateCompleted]) Then
Me.DateCompleted.Value = Date
BusinessDays DateReceived, DateCompleted
End If
End If