Access form dropdown multiple field validation.

psamu

Active Member
Joined
Jan 3, 2007
Messages
462
I would appreciate anyone help on this. I have a dropdown field " Active", "Ready", and "Completed". There are two other fields for date, Ready Date and Completed Date. If user use the drop down and select "Ready" immediately "Ready Date" need to be by default Today' Date. If User select "Completed" without "Ready Date". It should stop and say "Completed" must be selected first. If already "Ready " selected and "Ready Date" populated in " Ready Date" field then without error "Completed Date" need to be populated by default Todays Date. Thanks
 
Thank you so much I appreciate your time and patience. I think it works, let me try. Different scenarios. Thanks again
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
You're welcome. I didn't write any error handling code - would not know where to put it for you.
 
Upvote 0
Thank you. I changed the field names. Dropdown list are "Active", "Completed", and "Approved" . if selected "Completed" field name [Resolved Date] need to update and for "Approved" field name [Approved Date] need to update. Now I have below code.
<p>
Option Explicit:
Dim svOldValue As String

Private Sub Form_AfterUpdate()
Select Case Me.Status
Case "Completed"
If IsDate(Me.Resolved_Date) Then Me.Resolved_Date = Date 'must be in this order
If Not IsDate(Me.Resolved_Date) Then Me.Resolved_Date = Date
Case "Approved"
If IsDate(Me.Approved_Date) Then Me.Approved_Date = Date 'must be in this order
If Not IsDate(Me.Approved_Date) Then Me.Approved_Date = Date

If IsNull(Me.Resolved_Date) Or Me.Approved_Date = "" Then
MsgBox "You must enter a Completed Date before selecting 'Approved' status."
Me.Status = svOldValue
Exit Sub
End If
Case "Active"
With Me
.Resolved_Date = ""
.Approved_Date = ""
End With


End Select
svOldValue = Me.Status


End Sub

</p>
 
Upvote 0
following need to correct.:
If I select Approved first without having Completed Date(Although gives warning, Approved date wont clear from Approved Date field)
Resolved Date and Approved Date field date should be editable if necessary (By default today's date)
 
Upvote 0
You have put this code on the form AfterUpdate event, not the combo box AfterUpdate event.

You have 2 different controls being tested for null or empty string (""). Both tests are meant to be done on 1 control at a time.
Code:
If IsNull(Me.Resolved_Date) Or Me.Approved_Date = "" Then


Approved date wont clear from Approved Date field)
Use the examples above and write a line to set something to "" if that's what you need.


Resolved Date and Approved Date field date should be editable if necessary
So are they not editable? By this I presume you mean user should be able to type into them.
 
Last edited:
Upvote 0
Thank you. Yes by default it should give today's date as per the selection but it is up to user to change different date. Now I can change the date but when I save it goes back to today's date.
 
Upvote 0
Possibly because you have the code in the wrong event.
 
Upvote 0

Forum statistics

Threads
1,221,842
Messages
6,162,333
Members
451,760
Latest member
samue Thon Ajaladin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top