Hi all,
I have used this code before in previous databases but am now having issues of cboDesc1 = null and it shouldn't be. My sSQL is correct. The funny thing is when I run this code, the cboDesc1 box becomes dimmed out and unclickable but has no value. I am eventually going to have 3 cboDesc boxes that will populate based upon the value in sSQL but I can't even get the first one to work. I am not used to working with bound objects. These combo boxes are bound to the table... is that the problem? It shouldn't be ???
sSQL value is
"SELECT Desc1 FROM tblApplicationDescription WHERE [Application] = 'Tina Test' ORDER BY Desc1"
where cboDesc1 should value Tina1, cboDesc2 should value Tina2, etc.
These values are all in one table for one row of data
Private Sub cboApplication_AfterUpdate()
Dim sSQL As String
'MsgBox "The Code is Executing!"
'clear cboDesc1
Me.cboDesc1 = Null
sSQL = "SELECT Desc1 FROM tblApplicationDescription"
sSQL = sSQL & " WHERE [Application] = '" & Me.[cboApplication] & "' "
sSQL = sSQL & " ORDER BY Desc1"
'for debugging
'Debug.Print sSQL
Me.cboDesc1.RowSource = sSQL
'check if cboDesc1 has values
If IsNull(Me.cboDesc1.ItemData(0)) Then
Me.cboDesc1.Enabled = False
Else
Me.cboDesc1.Enabled = True
Me.cboDesc1 = Me.cboDesc1.ItemData(0)
'optional
Me.cboDesc1.SetFocus
Me.cboDesc1.Dropdown
End If
End Sub
I have used this code before in previous databases but am now having issues of cboDesc1 = null and it shouldn't be. My sSQL is correct. The funny thing is when I run this code, the cboDesc1 box becomes dimmed out and unclickable but has no value. I am eventually going to have 3 cboDesc boxes that will populate based upon the value in sSQL but I can't even get the first one to work. I am not used to working with bound objects. These combo boxes are bound to the table... is that the problem? It shouldn't be ???
sSQL value is
"SELECT Desc1 FROM tblApplicationDescription WHERE [Application] = 'Tina Test' ORDER BY Desc1"
where cboDesc1 should value Tina1, cboDesc2 should value Tina2, etc.
These values are all in one table for one row of data
Private Sub cboApplication_AfterUpdate()
Dim sSQL As String
'MsgBox "The Code is Executing!"
'clear cboDesc1
Me.cboDesc1 = Null
sSQL = "SELECT Desc1 FROM tblApplicationDescription"
sSQL = sSQL & " WHERE [Application] = '" & Me.[cboApplication] & "' "
sSQL = sSQL & " ORDER BY Desc1"
'for debugging
'Debug.Print sSQL
Me.cboDesc1.RowSource = sSQL
'check if cboDesc1 has values
If IsNull(Me.cboDesc1.ItemData(0)) Then
Me.cboDesc1.Enabled = False
Else
Me.cboDesc1.Enabled = True
Me.cboDesc1 = Me.cboDesc1.ItemData(0)
'optional
Me.cboDesc1.SetFocus
Me.cboDesc1.Dropdown
End If
End Sub