Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to change lable color

Status
Not open for further replies.

jw5107

Technical User
Joined
Jan 20, 2004
Messages
294
Location
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top