status validation help

G

Gabe

Hello, I need some help coding this one...

I have 3 fields in a form Amount, Date, and Status. If the user inputs an
Amount then they must enter a "Date" in order for the database to accept a
Complete "Status".

The Status field has several drop down choices, Open, Pending, Complete, etc.

Any help would be greatly appriciated!!

Thanks,
~Gabe
 
J

John W. Vinson

Hello, I need some help coding this one...

I have 3 fields in a form Amount, Date, and Status. If the user inputs an
Amount then they must enter a "Date" in order for the database to accept a
Complete "Status".

The Status field has several drop down choices, Open, Pending, Complete, etc.

Any help would be greatly appriciated!!

Thanks,
~Gabe

Use the Form's BeforeUpdate event to check that the data is valid; e.g.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me![Date]) AND Me![Status] = "Complete" Then
Cancel = True
MsgBox "Please enter a date before selecting COMPLETE"
End If
End Sub
 
L

Linq Adams via AccessMonster.com

OK, if the user inputs an Amount then they must enter a "Date" in order for
the database to accept a
Complete "Status." What if an amount is not input, can the status "Complete"
then be acceptable?

Also, if your field/control iss actually named "Date" you need to change that.
"Date" is a Reserved Word in Access VBA and you may very well confuse the
Access Gnomes!
 
G

Gabe

Yes, if they don't put an amount then the "Complete" status is still
acceptable, sometimes costs are not inccured but if they do put an amount in
then they must enter a date or "PaidDate" down before they can select a
complete status. MS should replace the gnomes with oompaloompas. =)
 
G

Gabe

That worked great, I had to tweak it a little...thank you John!

Private Sub Form_BeforeUpdate(Cancel As Integer)
If (Me![Amount]) <> 0 And IsNull(Me![PaidDate]) And Me![Status] = "Complete"
Then
Cancel = True
MsgBox "Please enter a date before selecting COMPLETE"
End If
End Sub

~Gabe

John W. Vinson said:
Hello, I need some help coding this one...

I have 3 fields in a form Amount, Date, and Status. If the user inputs an
Amount then they must enter a "Date" in order for the database to accept a
Complete "Status".

The Status field has several drop down choices, Open, Pending, Complete, etc.

Any help would be greatly appriciated!!

Thanks,
~Gabe

Use the Form's BeforeUpdate event to check that the data is valid; e.g.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me![Date]) AND Me![Status] = "Complete" Then
Cancel = True
MsgBox "Please enter a date before selecting COMPLETE"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top