error passing a string to a field reference

tanzania

Registered User.
Local time
Today, 08:10
Joined
Oct 20, 2006
Messages
91
Hi, I have the following code in which I am doing a loop through 24 fields of a table (rather than duplicate this code 24 times), but I get an automation error on DLookup("[strAdd]"...
What do I need to do pass this string in accuractley as the field Additional1 of my table?

Cheers

tania

Code:
 Set db = CurrentDb()
    Set rs = db.OpenRecordset("tblAdditionalFields", dbOpenDynaset)
    
    Dim count As Integer
    Dim strPos As String
    Dim strAdd As String
    Dim strNew As String
    
    For count = 1 To 24
        
        strAdd = "Additional" & CStr(count)
        strNew = "AddNew" & CStr(count)
        
        MsgBox strAdd
        MsgBox strNew
        
        If DLookup("[strAdd]", "tblCustomise") = False Then
    
            Me.txtAdditional1.Visible = False
        Else
            Me.txtAdditional1.Visible = True
            Me.LabelAdditional1.Caption = rs![strNew]
        End If
    Next count
 
Try:
If DLookup(strAdd, "tblCustomise") = False Then
 
DLookup() doesn't return a False if there's no match, it returns a Null.
 

Users who are viewing this thread

Back
Top Bottom