Multiple use procedure HELP HELP HELP

H

hansford.d.cornett

I have a database form with 10 field names in it.

EmpName Present or Not
Field1 Jay [ ]
Field2 Ray [x]
Field3 Fay [ ]
Field4 [x]

I have built a small form that I pop up when a field like
Field 4 has an x stating someone is present when there is
NO NAME present.

The code I use merely checks the Len of the
Field "EmpName" [FldLen].
If [FldLen] >0
FldError1 = "NO NAME PRESENT FOR THIS ENTRY, PLEASE
VERIFY."
OPEN FORM POPUP 1.

Endif

Form popup has a OK command button that closes the form.\

MY Problem is that I have to put this code into every
field to get it to work.

Can I put this Into a MODULE or PROCEDURE and then call it
into every field to do the check and pop up the ERROR FORM
when the len is Zero and a X has been entered into the
field PRESENT. If so how.

I tried to move this code into a module even made it
Global however I could not get it to work.

I used VarFldLen as Variable assigning Len([FieldName]) to
it but still could not get it to work..

HELP PLEASE......
 
J

John Vinson

I have a database form with 10 field names in it.

EmpName Present or Not
Field1 Jay [ ]
Field2 Ray [x]
Field3 Fay [ ]
Field4 [x]

I'm not sure I follow. This seems badly denormalized! If you have up
to ten employees and want to check their presence, then you should
have a one-to-many relationship to a table with (up to) ten ROWS,
rather than having ten (or twenty?) fields for ten names (and ten
yes/no fields).

The difficulty you're having stems from the non-normalized table
design.
I have built a small form that I pop up when a field like
Field 4 has an x stating someone is present when there is
NO NAME present.

The code I use merely checks the Len of the
Field "EmpName" [FldLen].
If [FldLen] >0
FldError1 = "NO NAME PRESENT FOR THIS ENTRY, PLEASE
VERIFY."
OPEN FORM POPUP 1.

Endif

Form popup has a OK command button that closes the form.\

MY Problem is that I have to put this code into every
field to get it to work.

Can I put this Into a MODULE or PROCEDURE and then call it
into every field to do the check and pop up the ERROR FORM
when the len is Zero and a X has been entered into the
field PRESENT. If so how.

You can write a public Function in a module, e.g.

Public Function DoStuff(Fieldname As String) As Boolean

and put

=DoStuff("Field1")

in the appropriate event of the Field1 control - but I'd REALLY REALLY
recommend stepping back and reconsidering your table structure! In a
normalized design the problem doesn't even come up!
 

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