Using the Call Function - Missing Reference

D

DJW

I was entering the same code on two different forms. I thought it would be
easier and create a module and in the module write the code once. Then I
thought I could just "call" the routine as a Public Sub. This the code
currently on my form called Hiring is:

Option Compare Database

Private Sub Form_Open(Cancel As Integer)

Call Verify

End Sub



The code below works on the form "Hiring" by itself as a Private Sub. I
know I'm on the right track as the message below in the stated Public Sub
when I call it is displayed. What I can't get it to do is run the code
after the message. It does not seem to want to reference the fields I have
on my form I called it from. It does not like the Me. reference. How do I
write the code to do the actions I want?


This is the code in my module (named Mod1)


Option Compare Database

Public Sub Verify()

MsgBox "Check the name"

If IsNull (Me!HireDate) Then
Me.HireDate= Now()
Me.ProgramName.Value = Me.Label0.Caption
Me.VersionInfo.Value = Me.Label1.Caption
End If

Thank you.


End Sub
 
J

J. Goddard

Hi -

You will have to pass the form reference to the module.

Change the Sub Verify () to

Sub Verify(CallingForm as form)
and change all the Me. references to Callingform. references.

Then, in the On open events, use Call Verify(Me)

Hope this helps

John
 

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