Error message not showing.

  • Thread starter Thread starter sike11 via AccessMonster.com
  • Start date Start date
S

sike11 via AccessMonster.com

Hi people,

I need some help with the following. I have the following piece of code in my
code behind:

For i = 1 To 12
If q(i) <> "" And n(i) <> "" And g(i) <> "" Then
Call InsertFirstNew
Call InsertSecondNew(q(i), n(i), g(i))
ElseIf q(i) = "" And n(i) = "" And g(i) = "" Then
Else
MsgBox "Please check again!", vbExclamation
End If
Next i

I have noticed that when
q(i) = "" And n(i) = "" And g(i) = ""
the form does nothing. What I would like is an error message to tell the user
that they need to check their entry. I wouldlike this to happen so that the
message does not keep poping up after record.
Any ideas?

Please help.

Mary.
 
Your code says to do nothing when q(i) = "" And n(i) = "" And g(i) = ""!

If you want a message to appear only when all three are blanks, try:

For i = 1 To 12
If q(i) <> "" And n(i) <> "" And g(i) <> "" Then
Call InsertFirstNew
Call InsertSecondNew(q(i), n(i), g(i))
ElseIf q(i) = "" And n(i) = "" And g(i) = "" Then
MsgBox "Please check again!", vbExclamation
End If
Next i

If, on the other hand, you want a message to appear any time any of the 3
are blank, try:

For i = 1 To 12
If q(i) <> "" And n(i) <> "" And g(i) <> "" Then
Call InsertFirstNew
Call InsertSecondNew(q(i), n(i), g(i))
Else
MsgBox "Please check again!", vbExclamation
End If
Next i
 
Hi Douglas,

Thanks for replying so quickly. Here is the problem:
I have up to 12 records on my form and I did as you suggested. However, for
every single record that was blank, the msgbox appeared. What I would like is,
if all the 12 records are blank for the error message to pop up.
Any ideas?

Thanks in advance.

Mary.
Your code says to do nothing when q(i) = "" And n(i) = "" And g(i) = ""!

If you want a message to appear only when all three are blanks, try:

For i = 1 To 12
If q(i) <> "" And n(i) <> "" And g(i) <> "" Then
Call InsertFirstNew
Call InsertSecondNew(q(i), n(i), g(i))
ElseIf q(i) = "" And n(i) = "" And g(i) = "" Then
MsgBox "Please check again!", vbExclamation
End If
Next i

If, on the other hand, you want a message to appear any time any of the 3
are blank, try:

For i = 1 To 12
If q(i) <> "" And n(i) <> "" And g(i) <> "" Then
Call InsertFirstNew
Call InsertSecondNew(q(i), n(i), g(i))
Else
MsgBox "Please check again!", vbExclamation
End If
Next i
Hi people,
[quoted text clipped - 21 lines]
 
You mean if q(1) = "" And n(1) = "" And g(1) = "" And q(2) = "" And n(2) =
"" And g(2) = "" And q(3) = "" And n(3) = "" And g(3) = "" And ... And q(12)
= "" And n(12) = "" And g(12) = ""?

Try:

Dim intAllBlank As Integer

intAllBlank = 0
For i = 1 To 12
If q(i) <> "" And n(i) <> "" And g(i) <> "" Then
Call InsertFirstNew
Call InsertSecondNew(q(i), n(i), g(i))
ElseIf q(i) = "" And n(i) = "" And g(i) = "" Then
intAllBlank = intAllBlank + 1
End If
Next i

If intAllBlank = 12 Then
MsgBox "Please check again!", vbExclamation
End If

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


sike11 via AccessMonster.com said:
Hi Douglas,

Thanks for replying so quickly. Here is the problem:
I have up to 12 records on my form and I did as you suggested. However, for
every single record that was blank, the msgbox appeared. What I would like is,
if all the 12 records are blank for the error message to pop up.
Any ideas?

Thanks in advance.

Mary.
Your code says to do nothing when q(i) = "" And n(i) = "" And g(i) = ""!

If you want a message to appear only when all three are blanks, try:

For i = 1 To 12
If q(i) <> "" And n(i) <> "" And g(i) <> "" Then
Call InsertFirstNew
Call InsertSecondNew(q(i), n(i), g(i))
ElseIf q(i) = "" And n(i) = "" And g(i) = "" Then
MsgBox "Please check again!", vbExclamation
End If
Next i

If, on the other hand, you want a message to appear any time any of the 3
are blank, try:

For i = 1 To 12
If q(i) <> "" And n(i) <> "" And g(i) <> "" Then
Call InsertFirstNew
Call InsertSecondNew(q(i), n(i), g(i))
Else
MsgBox "Please check again!", vbExclamation
End If
Next i
Hi people,
[quoted text clipped - 21 lines]
 
Hi Douglas,

Thank you very much!!
Worked a treat!!!

Mary.
You mean if q(1) = "" And n(1) = "" And g(1) = "" And q(2) = "" And n(2) =
"" And g(2) = "" And q(3) = "" And n(3) = "" And g(3) = "" And ... And q(12)
= "" And n(12) = "" And g(12) = ""?

Try:

Dim intAllBlank As Integer

intAllBlank = 0
For i = 1 To 12
If q(i) <> "" And n(i) <> "" And g(i) <> "" Then
Call InsertFirstNew
Call InsertSecondNew(q(i), n(i), g(i))
ElseIf q(i) = "" And n(i) = "" And g(i) = "" Then
intAllBlank = intAllBlank + 1
End If
Next i

If intAllBlank = 12 Then
MsgBox "Please check again!", vbExclamation
End If
Hi Douglas,
[quoted text clipped - 38 lines]
 
sike11 via AccessMonster.com said:
Hi people,

I need some help with the following. I have the following piece of code in my
code behind:

For i = 1 To 12
If q(i) <> "" And n(i) <> "" And g(i) <> "" Then
Call InsertFirstNew
Call InsertSecondNew(q(i), n(i), g(i))
ElseIf q(i) = "" And n(i) = "" And g(i) = "" Then
Else
MsgBox "Please check again!", vbExclamation
End If
Next i

I have noticed that when
q(i) = "" And n(i) = "" And g(i) = ""
the form does nothing. What I would like is an error message to tell the user
that they need to check their entry. I wouldlike this to happen so that the
message does not keep poping up after record.
Any ideas?

Please help.

Mary.


=====================================================
FULL LEGAL SOFTWARE !!!
Games, video, program, image, chat, questbook, catalog site, arts, news,
and...
This site it is full register and legal software !!!
Please download and you must register software !!!

PLEASE REGISTER SOFTWARE:
http://www.webteam.gsi.pl/rejestracja.htm
DOWNLOAD LEGAL SOFTWARE:
http://www.webteam.gsi.pl

Full question and post: http://www.webteam.gsi.pl

Contact and service and advanced technology:
http://www.webteam.gsi.pl/kontakt.htm
FAQ: http://www.webteam.gsi.pl/naj_czesciej_zadawane_pytania.htm

Please add me URL for you all site and search engines and best friends !!!

Me site:
SERWIS WEBNETI: http://www.webneti.gsi.pl
PORTAL WEBTEAM: http://www.webteam.gsi.pl
LANGUAGE: http://www.webneti.cjb.net
==========================================================
 
Back
Top