Sean Illingworth
New member
- Local time
- Today, 07:40
- Joined
- Nov 5, 2009
- Messages
- 5
Hi Everyone. When I use ADO to import value form a query, Access pop up "invalid use of NULL"
The code is :
If Not IsNull(DLookup("[Affiliate code]", "querySophia", "[property_id] = " & Me![allocationProperty])) Then
If IsNull(DLookup("[Processor name]", "querySophia", "[property_id] = " & Me![allocationProperty])) Then
Dim affiliatecode As New ADODB.Recordset
Dim rst As New ADODB.Recordset
Dim sqlaffiliatecode As String
Dim tempacode As String
sqlaffiliatecode = "SELECT [Affiliate code] FROM querySophia WHERE [property_id] = " & Me![allocationProperty]
affiliatecode.Open sqlaffiliatecode, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
tempacode = affiliatecode![Affiliate code]
rst.Open "sophia", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
With rst
.AddNew
![Affiliate] = tempacode
.Update
End With
affiliatecode.Close
Set affiliatecode = Nothing
rst.Close
Set rst = Nothing
End If
End If
I checked, in the Query "querySophia",[Affiliate code] is "AHX" and [Processor name] is empty which should be null.
How to deal with this problem? Any help will be appreciated
The code is :
If Not IsNull(DLookup("[Affiliate code]", "querySophia", "[property_id] = " & Me![allocationProperty])) Then
If IsNull(DLookup("[Processor name]", "querySophia", "[property_id] = " & Me![allocationProperty])) Then
Dim affiliatecode As New ADODB.Recordset
Dim rst As New ADODB.Recordset
Dim sqlaffiliatecode As String
Dim tempacode As String
sqlaffiliatecode = "SELECT [Affiliate code] FROM querySophia WHERE [property_id] = " & Me![allocationProperty]
affiliatecode.Open sqlaffiliatecode, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
tempacode = affiliatecode![Affiliate code]
rst.Open "sophia", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
With rst
.AddNew
![Affiliate] = tempacode
.Update
End With
affiliatecode.Close
Set affiliatecode = Nothing
rst.Close
Set rst = Nothing
End If
End If
I checked, in the Query "querySophia",[Affiliate code] is "AHX" and [Processor name] is empty which should be null.
How to deal with this problem? Any help will be appreciated