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

Autofill Text Box from Cascading Combobox

Status
Not open for further replies.

Dawnit

Technical User
Apr 2, 2001
76
US
Hi,

I have a triple cascading combo box setup that works completely fine. The trouble I’m having is getting a text box related to the second combo box to autofill based on a selection, and I've spent more than 8 hours trying to figure it out! Here's the senario:

The user selects a Class description from the first combo box, and the text box next to it autofills perfectly with a related value (from a row source sql query).
Then the user selects a ClassSeries from the second combo box, and the text box next that combo box is supposed autofill with a value (from a diferent row source sql query) related to the second combo box, but it doesn’t. This is where I need help.

Here is my After Event coding:

Private Sub cboClassID_AfterUpdate()
Me.cboClassSeriesID.RowSource = "SELECT [UFS-ClassSeries].SeriesID, [UFS-ClassSeries].SeriesDescrip FROM [UFS-ClassSeries] " & _
" WHERE ClassID = " & Nz(Me.cboClassID) & _
" ORDER BY SeriesDescrip"
Me.cboClassSeriesID = Null

Me.Textbox1 = Me.cboClassID.Column(2)

EnableControls

End Sub

Private Sub cboClassSeriesID_AfterUpdate()
Me.cboSubSeriesID.RowSource = "SELECT [UFS-SubSeries].SubSeriesID, [UFS-SubSeries].SubDescrip FROM [UFS-SubSeries] " & _
" WHERE SeriesID = " & Nz(Me.cboClassSeriesID) & _
" ORDER BY SubDescrip"
Me.cboSubSeriesID = Null

Me.Textbox2 = Me.cboClassSeriesID.Column(2)

EnableControls

End Sub


Private Sub EnableControls()

' Clear the combo boxes

If IsNull(Me.cboClassID) Then
Me.cboClassSeriesID = Null
End If

' Enable or disable combo boxes based on whether the combo box preceeding it has a value.
Me.cboClassSeriesID.Enabled = (Not IsNull(Me.cboClassID))
Me.cboSubSeriesID.Enabled = (Not IsNull(Me.cboClassSeriesID))

End Sub

IMPORTANT NOTE: This is the code (included above) that “seems” to be the problem - Me.Textbox2 = Me.cboClassSeriesID.Column(2) The weird thing is if I simply change the (2) to (0) or (1), then the text box is populated accordingly.

I sure hope someone can help!!!!

Dawnit :)
 
How are ya Dawnit . . .

Dawnit said:
[blue]The weird thing is if I simply change the (2) to (0) or (1), then the text box is populated accordingly.[/blue]

You are correct ... note that column index [purple]starts at zero (0)[/purple]!

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Yes, I was aware of that. Any suggestion as to why the text box won't populate when I set the column index to (2)? The data I want auto populated is in that column.

Thanks!
 
cboSubSeriesID has only 2 columns due its RowSource.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I'll look at this Monday, as I'm off work until then. I'll check in with the results. Thanks much!
 
Hi there!

I'm back to report that looking into your point that cboSubSeriesID has only 2 columns did not lead me anywhere, so I sure could use another hint or two. And I'm not sure I was clear in presenting my problem originially. My trouble is getting the second text box (Textbox2) to auto populate depending on my selection of the second combo box (cboClassSeriesID). The functionality of cascading combo boxes work just fine.

I sure hope you can shed some light!

Thanks!
 
Me.cboClassSeriesID.RowSource = "SELECT [UFS-ClassSeries].SeriesID, [UFS-ClassSeries].SeriesDescrip FROM [UFS-ClassSeries] " & _
Two columns only here too...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV,

Thanks for getting back to me so soon! I got it!!! You were refering to my combo box property, event, VB code, not the property, "row source" sql query.

Oh my gosh, what a relief!!! Thank you so much!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top