Check for missing data

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

sike11 via AccessMonster.com

Hi,

I wonder if you can help. I have a form which inputs qualification details
into a table. During testing, I notice that when I miss data from one of the
fields, I do get an error message. The form then refreshes rather than all
the details being left as it is for the user to correct the details. Below is
the code I am using. Please help.

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
Else
MsgBox "Please check again!", vbExclamation
End If
Next i

If intAllBlank = 12 Then 'If all records are blank
MsgBox "Please check again!", vbExclamation
Else
If intAllBlank < 12 Then 'If records are not blank
Call ClearForm
End If
End If

How would I modify the code to print the error message and leave the details
as they are in the form?

Regards,

Mary.
 
I would assume it has something to do with this code:

If intAllBlank < 12 Then 'If records are not blank
Call ClearForm
End If
 
Hey Douglas,

You are right. When I took the code out, it seemed to work. Then I got the
problem of when the user had completed the form as required? It would not
refresh. Any ideas?

Regards,

Mary.
I would assume it has something to do with this code:

If intAllBlank < 12 Then 'If records are not blank
Call ClearForm
End If
[quoted text clipped - 29 lines]
 
To be perfectly honest, I have no idea what you're doing in your form!

Why i = 1 to 12? What are q(i), n(i) and g(i)?

Does the user have to provide values for all 12 rows? If so, then

If intAllBlank = 0 Then
Call ClearForm
End If

is probably what you want.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


sike11 via AccessMonster.com said:
Hey Douglas,

You are right. When I took the code out, it seemed to work. Then I got the
problem of when the user had completed the form as required? It would not
refresh. Any ideas?

Regards,

Mary.
I would assume it has something to do with this code:

If intAllBlank < 12 Then 'If records are not blank
Call ClearForm
End If
[quoted text clipped - 29 lines]
 
Hi Douglas,

Let me try and clarify.
The form has 2 textboxes - surname and firstname. The user searches using
those 2.
There are 12 rows consisting of:
qualification reference q(1), qualification name n(i) and qualification
grade g(i)

The user may enter as many rows as they wish but the maximum is 12. They do
not have to provide values for all the rows. After they have done that, they
need to update to the designated table.
Thing is after searching for the desired name, if the user makes an error and
presses the update button before entering records or misses out on part of
the information, I would like an error message to show and take the user back
to the form for them to make corrections. Once corrections are made and
update is pressed, the form should refresh.

Is this possible?

Regards,

Mary


To be perfectly honest, I have no idea what you're doing in your form!

Why i = 1 to 12? What are q(i), n(i) and g(i)?

Does the user have to provide values for all 12 rows? If so, then

If intAllBlank = 0 Then
Call ClearForm
End If

is probably what you want.
Hey Douglas,
[quoted text clipped - 17 lines]
 
Back
Top