Vb Help

Beerman3436
08-19-2003, 11:38 AM
I am trying to use this code to print in a report but it give me the following error.

The Value you entered isn't valid for this field

It is because I am getting the top 3 values from the query and only 1 is showing up on the report. I need the other fields to just be blank if there is only 1 value passed.

Here is the code:

Set rst = New ADODB.Recordset
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CodeProject.Connection
.Source = "Select TOP 3 [District Name],[OLDEoy],[NewEOY] From qryCover WHERE [Star2] = '*' ORDER BY [District Name]"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open , , adCmdText
End With
If IsNull(rst![District Name]) Then
Me.LargeOver1 = Null
Else
Me.LargeOver1 = rst![District Name]
Me.Large1 = rst!OldEOY
Me.New1 = rst!NewEOY
End If
rst.MoveNext
If IsNull(rst![District Name]) Then
Me.LargeOver2 = Null
Else
Me.LargeOver2 = rst![District Name]
Me.Large2 = rst!OldEOY
Me.New2 = rst!NewEOY
End If
rst.MoveNext
If IsNull(rst![District Name]) Then
Me.LargeOver3 = Null
Else
Me.LargeOver3 = rst![District Name]
Me.Large3 = rst!OldEOY
Me.New3 = rst!NewEOY
End If
rst.Close
Set rst = Nothing

NoahBody
08-19-2003, 03:43 PM
SQL Server or Access??

If SQL Server, did you try the query in the Query Analyzer??

Or Access, did you start a new query and plug the line in the SQL window to be sure it's correct??

I think your comparing for the single character asterisk. Don't you have to use Like when using wildcards?? Because you'll get that error if the field is numeric, I think.

->N

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum