L
Louie Warren
What is this error and why am I getting it? Thanx!
Code:
Private Sub ComboBoxField_GotFocus()
Dim lngRed As Long, lngBlue As Long, lngGreen As Long,
lngBlack As Long
Dim TypeId As Long
Dim lngState As Long
Dim strSQL As String
strSQL = "SELECT tTypes.TypeId " & _
"FROM tTypes INNER JOIN tPeople ON
tTypes.TypeId = tPeople.TypeFK " & _
"WHERE tPeople.Id = '" &
Forms.fMyForm.ComboBoxField & "';"
Dim daoDatabase As DAO.Database
Set daoDatabase = CurrentDb
Dim daoQueryDef As DAO.QueryDef
Set daoQueryDef = daoDatabase.QueryDefs
("qry$DynamicSQL")
daoQueryDef.SQL = strSQL
DoCmd.OpenQuery "qry$DynamicSQL", acViewNormal,
acReadOnly
lngGreen = RGB(75, 200, 100)
lngBlue = RGB(0, 0, 255)
lngBlack = RGB(50, 50, 50)
lngRed = RGB(200, 0, 0)
If TypeId = 1 Then
Field.Caption = "Type 1"
Field.ForeColor = lngGreen
End If
If TypeId = 2 Then
Field.Caption = "Type 2"
Field.ForeColor = lngBlue
End If
If TypeId = 3 Then
Field.Caption = "Type 3"
Field.ForeColor = lngBlack
End If
If TypeId = 4 Then
Field.Caption = "Type 4"
Field.ForeColor = lngRed
End If
End Sub
Code:
Private Sub ComboBoxField_GotFocus()
Dim lngRed As Long, lngBlue As Long, lngGreen As Long,
lngBlack As Long
Dim TypeId As Long
Dim lngState As Long
Dim strSQL As String
strSQL = "SELECT tTypes.TypeId " & _
"FROM tTypes INNER JOIN tPeople ON
tTypes.TypeId = tPeople.TypeFK " & _
"WHERE tPeople.Id = '" &
Forms.fMyForm.ComboBoxField & "';"
Dim daoDatabase As DAO.Database
Set daoDatabase = CurrentDb
Dim daoQueryDef As DAO.QueryDef
Set daoQueryDef = daoDatabase.QueryDefs
("qry$DynamicSQL")
daoQueryDef.SQL = strSQL
DoCmd.OpenQuery "qry$DynamicSQL", acViewNormal,
acReadOnly
lngGreen = RGB(75, 200, 100)
lngBlue = RGB(0, 0, 255)
lngBlack = RGB(50, 50, 50)
lngRed = RGB(200, 0, 0)
If TypeId = 1 Then
Field.Caption = "Type 1"
Field.ForeColor = lngGreen
End If
If TypeId = 2 Then
Field.Caption = "Type 2"
Field.ForeColor = lngBlue
End If
If TypeId = 3 Then
Field.Caption = "Type 3"
Field.ForeColor = lngBlack
End If
If TypeId = 4 Then
Field.Caption = "Type 4"
Field.ForeColor = lngRed
End If
End Sub