Imdabaum
07-26-2006, 12:45 PM
I am trying to pull one value from a table to attach an image. If there is an image associated with the ID then it gets loaded, if there isn't one then it doesn't need to do anything. The problem is this.
Dim strSQL As String
Dim db As Database
Dim rst As Recordset
Dim qry As QueryDef
Set db = CurrentDb
strSQL = "SELECT location FROM tblDisplayImages WHERE PropertyID= " & Me.txtID
Set qry = db.CreateQueryDef("getDisplayImage", strSQL)
Set rst = qry.OpenRecordset
db.QueryDefs.Delete ("getDisplayImage")
If rst.Fields("location").Value <> Null Then
titleImage.Picture = rst.Fields("location")
End If
Exit_Form_Current:
Exit Sub
Err_Current:
If Err.Number <> 3021 Then
MsgBox Err.Number & ": " & Err.Description & "; " & Err.Source
Else
Resume Next
End If
End Sub
I just want to test if the rst.Fields("location") has a value in the field. But if I try to test if the value exists, it gets an error I have tried to handle the 3021 error, No Data in Record. But It won't Skip the step and gets caught.:banghead:
Dim strSQL As String
Dim db As Database
Dim rst As Recordset
Dim qry As QueryDef
Set db = CurrentDb
strSQL = "SELECT location FROM tblDisplayImages WHERE PropertyID= " & Me.txtID
Set qry = db.CreateQueryDef("getDisplayImage", strSQL)
Set rst = qry.OpenRecordset
db.QueryDefs.Delete ("getDisplayImage")
If rst.Fields("location").Value <> Null Then
titleImage.Picture = rst.Fields("location")
End If
Exit_Form_Current:
Exit Sub
Err_Current:
If Err.Number <> 3021 Then
MsgBox Err.Number & ": " & Err.Description & "; " & Err.Source
Else
Resume Next
End If
End Sub
I just want to test if the rst.Fields("location") has a value in the field. But if I try to test if the value exists, it gets an error I have tried to handle the 3021 error, No Data in Record. But It won't Skip the step and gets caught.:banghead: