Simple Code

Samand

Registered User.
Local time
Today, 10:45
Joined
May 14, 2013
Messages
10
I know tha this is basic but I can't figure it out as I am a novice.
I am trying to get some code so that when I I just Put expr1: Func() into a field it will come back with the needed result. I have come up with:
Code:
Public Function Func() As String
        
    Dim temp As String
    Dim var1 As Variant
    Dim var2 As Variant
    
    var1 = [table1]![col1]
    var2 = [table2]![col2]
    
    If Not IsNull(var1) And Not IsNull(var2) Then
        temp = "Yes"
    Else: temp = "No"
    End If
    
    Func = temp
End Function
but this isn't doing the trick:banghead:
 
You can't refer to a table value that way. You either need to open a recordset, use DLookup(), or have the values available on a form.
 
Sorry there is a mistake in the prev code. Should be:
Code:
    var1 = [table1]![col1]
    var2 = [table1]![col2]

I need the code to calculte the result for every row, not a specific one.
 
Thanks, I was hoping there was an easier way as in total I need to use 6 columns.
 
Well, not knowing the actual goal I'll simply say that adding parameters to the function would be quite easy.
 

Users who are viewing this thread

Back
Top Bottom