"Each" control Required in module

T

top4747

I have created a look-up database where a firm name is required by
using the following module:

Dim ctl As Control
Dim CheckFlag As Integer

CheckFlag = 0

For Each ctl In Me.Controls
If ctl.Tag = "Required" Then
If Len(ctl & "") = 0 Then
MsgBox "Please key portion of Firm Name."
ctl.SetFocus
Cancel = True
CheckFlag = 1
Exit For
End If
End If
Next

With this module, for each 'required' tagged text box, there needs to
be a value input. However, I want the end user to be able to key in
either firm name OR zip code into their individual text boxes. With
the above module, it is currently set up so that they jsut have to key
in firm name. If i tag the Zip code text bos as required, they need to
key both fields. Is there any way to make it so that i can have one OR
the other required and not BOTH???

Any help would be GREAT!!!!!!!!
 
D

Duane Hookom

I would set the tags of the OR controls to something like:
Control: txtFirmName
Tag: Required;txtZipCode
and
Control: txtZipCode
Tag: Required;txtFirmName

Then modify your code like:
If Instr(ctl.Tag,"Required") > 0 Then
and have a test for the extra control for null.
 

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