How to show a messagebox on null textbox or wrong data??

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

I have this code that inserts whatever is in txtGrade into an
enrollment table.

DoCmd.SetWarnings False


would I just insert code that said:
if txtgrade "" then
msgbox "Enter all grades"
else
DoCmd.OpenQuery "querytoinsertgrade"

What if I wanted to make sure the grades were either A, B, C, D, or F
and nothing else, so if something other than those was entered in
txtgrade I would get a textbox that said that all grades are not right
and to redo them??

how would I do something like this?
 
If Len(Me.txtGrade & "") = 0 Then
MsgBox "Enter all Grades"
Else
Select Case Me.txtGrade
Case "A", "B", "C", "D", "F"
DoCmd.OpenQuery "querytoinsertgrade"
Case Else
MsgBox "Invalid Grade"
End Select
End If

On the other hand, if you're trying to limit the input, why not use a combo
box rather than a text box?
 

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

Back
Top