Below is an example of the code I am working with...
The problem is the query qryAllocatedIID - it has criteria like: [Forms]![WWReviewHelper]![IID]. There is a txtbox on the form named IID. When Box388 is clicked - I get an error stating - Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
Is there a way that I could put criteria in the code below to look at the IID on the form and the IID in the query - to change the color of the label?
Right now I have make table querys, and I am trying to find a way to make this all run faster & minimize bloat.....
Any suggestions or examples??
Thanks in advance!!
jw
Private Sub Box388_Click()
Dim rstAllocatedIID As New ADODB.Recordset
Dim i As Integer
Dim ctrl As Control
' Open a recordset based on the WWReviewhelper query.
rstAllocatedIID.Open "qryAllocatedIID", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
' If no allocations are set.
If rstAllocatedIID.EOF Then '16711680
Exit Sub
End If
'loop through form controls
For Each ctrl In Me.Controls
If TypeOf ctrl Is Label Then
With rstAllocatedIID
.MoveFirst
For i = 1 To .RecordCount
If ctrl.Caption = !GTWY Then
ctrl.ForeColor = 16711680
End If
.MoveNext
Next i
End With
End If
Next
End Sub
The problem is the query qryAllocatedIID - it has criteria like: [Forms]![WWReviewHelper]![IID]. There is a txtbox on the form named IID. When Box388 is clicked - I get an error stating - Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
Is there a way that I could put criteria in the code below to look at the IID on the form and the IID in the query - to change the color of the label?
Right now I have make table querys, and I am trying to find a way to make this all run faster & minimize bloat.....
Any suggestions or examples??
Thanks in advance!!
jw
Private Sub Box388_Click()
Dim rstAllocatedIID As New ADODB.Recordset
Dim i As Integer
Dim ctrl As Control
' Open a recordset based on the WWReviewhelper query.
rstAllocatedIID.Open "qryAllocatedIID", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
' If no allocations are set.
If rstAllocatedIID.EOF Then '16711680
Exit Sub
End If
'loop through form controls
For Each ctrl In Me.Controls
If TypeOf ctrl Is Label Then
With rstAllocatedIID
.MoveFirst
For i = 1 To .RecordCount
If ctrl.Caption = !GTWY Then
ctrl.ForeColor = 16711680
End If
.MoveNext
Next i
End With
End If
Next
End Sub