Forgive me but I think that I might be a little dense. I have read a number of articles on populating one combo box based on another. I'm not understanding it very well and I'm hoping someone here can break it down barney style for me. I have:
tbl_RMS
[RawMaterial] [SpecLvl]
101114 | 4
101114 | 5
210225 | 1
On a form: I have one combo box set with a rowsource of [RawMaterial] from tbl_RawMaterial (A different table). My second combo box is a simple list of 1-16. Right now the user has to already know what spec is available for viewing. I'd like to make it simpler and, via VBA, set the a rowsource of combo box #2 to be 4-5 automatically. Here's what I have so far (plase don't laugh):
Code:
Private Sub RM_Click()
With Me![SpecLvl]
If IsNull(Me!RM) Then
.RowSource = ""
Else
.RowSource = "SELECT [SpecLevel] " _
& "FROM tbl_RMS " _
& "WHERE tbl_RMS.[RawMaterial] = Me!RM;"
End If
End With
End Sub
When I use this code, [SpecLvl] is prepopulated with "SELECT" and not 4-5 when I type in 101114.
I've also tried:
Code:
Private Sub RM_Click()
Dim sSQL As String
sSQL = "SELECT [SpecLevel] " _
& "FROM tbl_RMS " _
& "WHERE tbl_RMS.[RawMaterial] =" & Me!RM
With Me![SpecLvl]
If IsNull(Me!RM) Then
.RowSource = ""
Else
.RowSource = sSQL
End If
End With
End Sub