Beerman3436
Registered User.
- Local time
- Today, 21:07
- Joined
- Mar 29, 2000
- Messages
- 29
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
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