populating list boxes VBA

mikevds

Music Library
Local time
Today, 14:41
Joined
Apr 29, 2005
Messages
69
I have a Hymnals table I am trying to link up with authors, so each author associated with the one list box displays a subform or second list box with the name of the song
The problem I have with VBA is no guidence in terms of the language here is the coding I did for a author database so it will populate from author name to cd name

Private Sub Combo16_AfterUpdate()
On Error Resume Next
Combo14.RowSource = "Select NamID, AuthorName " & _
"FROM tblAuthorName " & _
"WHERE AuthorType = " & Combo16.Value & _
" ORDER BY NamID;"

IS this the correct coding for

Private Sub Combo16_AfterUpdate()
On Error Resume Next
Combo14.RowSource = "Select NamID, AuthorName " & _
"FROM tblAuthorName " & _
"WHERE AuthorType = " & Combo16.Value & _
" ORDER BY NamID;"


Private Sub Combo14_AfterUpdate()
On Error Resume Next
Combo18.RowSource = "Select ID,Hymnal " & _
"FROM HymnalSonginfo " & _
"WHERE authornumber = " & Combo14.Value & _
" ORDER BY HymnalNAme

Private Sub Combo16_AfterUpdate()
On Error Resume Next
Combo14.RowSource = "Select NamID, AuthorName " & _
"FROM tblAuthorName " & _
"WHERE AuthorType = " & Combo16.Value & _
" ORDER BY NamID;"
End Sub
Private Sub Combo18_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Me![Combo18])
Me.Bookmark = rs.Bookmark
End Sub

So if I have on list box hymnal author the other one hymnal name and name of song, it should populate like that.
Where is their a website or book that would generate the code for you autoatically, I live in the NJ area and would like to take a course on it.

I have a Learn Access 2003 vba book but it don't seem to cover populating two list boxes I have spent a few months learning the vba and setting up the db I use for the hymnals
 
It may be simpler to refer to the relevant comboboxes in the query builder.

Then the afterupdate code is simply Combo16.Requery

e.g.
Private Sub Combo16_AfterUpdate()
Combo14.Requery
End Sub
 

Users who are viewing this thread

Back
Top Bottom