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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call Procedure from module 2

Status
Not open for further replies.

access345

Programmer
Nov 23, 2005
78
US
I have created a module called LookupValues. I have been trying to call this module from a form. I can't seem to get the scope correct so the call statement works:

Here is what I have:
From the Form:

Private Sub RefDesig1_Exit(Cancel As Integer)
'Call LookupValue (0)

End Sub

From the Module:
Public Sub LookupValues()
Dim X, Y As String
On Error GoTo ERR_txtRefDesig

Dim FormName As String
Dim TableName As String
Dim EntryTextBox As String
Dim DisplayTextBox1 As String
Dim LookupValueFromTable1 As String


TableName = "TblPartsList"
FormName = "frmInitialInspectionDefect"
EntryTextBox = "txtRefDesig"
DisplayTextBox1 = "txtPartDescription"
LookupValueFromTable1 = "PartDescription"


Forms![FormName]![DisplayTextBox1] = DLookup("[LookupValueFromTable1]", "TableName", "[EntryTextBox] = Forms![FormName]!EntryTextBox")

Exit Sub
ERR_txtRefDesig:
MsgBox "Information not available. Contact Administrator x412"
Exit Sub

End Sub

Help is appreciated
 
In your call, you may want to replace LookupValue(0) with LookupValues(0).

It would also help to remove the apostrophe before your call.

Hope this helps,

Alex

A wise man once said
"The only thing normal about database guys is their tables".
 
I changed the name to Call LookupValues(0)

When I try to compile I get the following error:

Compile error:
expected variable or procedure, not module
 
Granted modules aren't my strong suit, but it looks sort of odd to me that in the sub Public Sub LookupValues() you have as an error handler On Error GoTo ERR_txtRefDesig

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Is your module called LookupValues?

If so, try changing both the call and sub name to LookupValue()

Whenever I call to a module I usually specify the module name, just to make it easier to track down the sub in question for anyone else needing to work in there. NOt sure where this falls on the 'best practices' continuum, but it makes maintenance much easier. This might help you out.

Hope this helps,

Alex

A wise man once said
"The only thing normal about database guys is their tables".
 
Thanks both sugestions made my call procedure work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top