Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing The Current Form Name For Use In Public Function 1

Status
Not open for further replies.

xweyer

MIS
Sep 7, 2000
140
US

I have a local procedure that checks that all the "required" fields have not been left empty (via the control's tag property) prior to saving the record. Since I have to do this for multiple forms I'd like to make this into a global function but can't figure how to pass the name of the current form in a way that doesn't produce errors. I tried a string variable but that produced a type mismatch.

The original line that I'm trying to make global is
For Each ctl In Me.Controls

Any suggestions?
 
Passing Me.Name in as a string to your function should do the trick.

John
 
How about...
Code:
Call CheckRequiredFields(Me)

Public Function CheckRequiredFields(frmName As Form)
   Dim ctl As Control
   For each ctl in frmName
      [i]the rest of your code goes here[/i]
   Next ctl
End Function


Randy
 
I didn't have any luck with the string variable. Couldn't get around the "type mismatch" error anyway that I tried it even though syntactically the string text appeared to be correct.

Randy's method worked perfectly for me though.

Thanks for the help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top