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
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