Required Field in Datasheet View

Hello, I am a beginner when it comes to Access (probably giving me too much credit).  I have a subform in datasheet view with several fields.  One field is a combo box and the second is a text box.  I would like to make an entry in the text box required only when one of the selections from the combo box is selected and not required for any other selection.  Is this possible and if so how?  Thank you.
medic2069Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbizupCommented:
You could use VBA in the form's Before Update event:

Private Sub Form_BeforeUpdate(cancel as integer)
    If me.cboMyCombo = SomeSelection and nz(me.txtMyTextbox,"") = ""       then           '<--- checks for combo selection and blank/null textbox
           msgbox "You need to fill in the textbox for this selection in the combo"
           Cancel = True      '<----- cancels the update
   end if
end sub

You will need to substitute your own combo and textbox names for the above code to work.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Yes

Put this code in the BeforeUpdate event of your Form - which will look like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
   
    If IsNull(Me.Text1) AND Me.Combo1 = "YourRequiredValue" Then
          MsgBox "Please enter value in text box"
          Cancel = True              ' ** cancels the update
     End If

End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
I see you are gittin back at me for last night.  Why don't you go to be EARLY tonight, lol.

AND ... I wish YOU  ... would have got STUCK on the Q last night like did !!

mx
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mbizupCommented:
Hee hee!   I figured you had it nailed, and unsubbed :-)
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
btw ... a P57 concurs ... it is TIME for the Neglected Q's to go :-)

mx
0
medic2069Author Commented:
Thank you for your help.  I tried mbizup's method and I kept getting an error.  Thanks again.  Have a great day!!!
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
You are welcome ...

So much for 'hee hee' ha ha ... but the two solutions were basically the same.  Hummmm.

mx

0
mbizupCommented:
Thanks for pointing that out, Joe :-)
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Maybe it was the non-string of
f me.cboMyCombo = SomeSelection

Some Selection ??

Sorry ...

Side note ... why don't the EE engineers fix the Upload ...>>>

See this Q ... near the bottom - upload issue

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_23132589.html

mx
0
mbizupCommented:
Hi Joe,

I don't think that is a new problem.  I noticed issues with posting just the quesiton ID some time ago and have always been using the full URL since then.  If this doesn't describe the problem as you are seeing it, send me an email (or use the Private Discussion thread... I'd like to see people start posting there.  I think that it is beneficial to all the experts subscribed to be aware of any issues with or on the site)

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.