I've written the following routine which I call from the click event of an OK button on a custom dialog form:<br><br>Function UseDialog(strNameDialog As String, ctlText As Control)<br><br>'This procedure insures that the user has entered a project<br>'number into the text box named txtProjNum. If a project<br>'number has not been entered, the user is reminded with a<br>'message box.<br><br> 'Inspect text box for user input and display<br> 'reminder if box is empty<br>If IsNull(ctlText) Then<br> 'Arguments for MsgBox<br> mstrMsg = "Please enter a project number in the text box."<br> mintStyle = vbExclamation + vbOKOnly<br> mstrTitle = "WHOOPS! NO PROJECT NUMBER"<br> 'Call message box function<br> MsgBox mstrMsg, mintStyle, mstrTitle<br> 'Move focus to text box for project number<br> DoCmd.GoToControl(ctlText) <br>Else<br> 'Or hide dialog while data transfers to main form<br> Forms("fdlgEnterProjectNumber"
.Visible = False<br>End If<br><br>End Function<br><br>This is the line I use to call the function:<br> Call UseDialog("fdlgEnterProjectNumber", txtProjNum)<br>Everything seems to be working fine except the line<br> DoCmd.GoToControl(ctlText)<br>I'm getting a message that I've used the GoToControl method without including a control name. How do I refer to the control named "txtProjNum" using the variable "ctlText" which I passed from the call?<br><br>Also, if I replace the line<br> Forms("fdlgEnterProjectNumber"
.Visible = False<br>with<br> Forms.strFormName.Visible = False<br>a message tells me that the "object doesn't support this property or method."<br><br>What am I missing here? I'm a little new at this. I can get the code to work in the form module using "Me" to reference the form, but I'd like to progress beyond that and learn to put most of the code in functions separate from the forms so they'll run faster. Sure could use some help. Thanks in advance, wdennis <br> <br>