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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Issues

Status
Not open for further replies.

tbassngal

Programmer
Feb 18, 2003
74
0
0
US
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
 
Okay, I think I have it figured out but how would I make it so that the Desc1 was populated 3 times without having to copy and paste code 3 times. Loop ??? I haven't done this in such a long time... ???
 
tbassngal . . .

You have two methods to try in thread702-1659596. As for comboboxes in tables ... see:
The Evils of Lookup Fields in Tables

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top