badinjector
Programmer
I am trying to add records to a table that has two primary keys. There are several tables in the db, but the ones of interest are:
tblCompetencies with compid and comptext as fields
tblCourses with courseid and coursename as fields
tblmatched with compid and courseid as key fields
I'm new to access and i have tried several things. Ideally, for quick data entry i would like to have a list box populated with courses and the user can select multiple courses, then click a command button that will append the record(s) (a competency paired with a course, or several pairs added at the same time). The form has a dropdown for the competency. I'm a little confused as how to do this.Some thoughts I had:
' Loop through the selected items in the list box and build a text string
If Me!Lstcourses.ItemsSelected.Count > 0 Then
For Each varItem In Me!Lstcourses.ItemsSelected
strCriteria = strCriteria & "tblcourses.courseid = " & Chr(34) & Me!Lstcourses.ItemData(varItem) & Chr(34) & "OR "
Next varItem
strCriteria = Left(strCriteria, Len(strCriteria) - 4)
' ok i think i'm setting the strCriteria above to tblcourses.courseid="#selected" or is this setting it to text??? i did get a type mismatch trying variations of this
Else
MsgBox "Select An Item From The List First"
Exit Sub
End If
strSQL = "INSERT INTO tblmatched [courseid, compid]
ok thats all i get thats of any use..
any help greatly appreciated
tblCompetencies with compid and comptext as fields
tblCourses with courseid and coursename as fields
tblmatched with compid and courseid as key fields
I'm new to access and i have tried several things. Ideally, for quick data entry i would like to have a list box populated with courses and the user can select multiple courses, then click a command button that will append the record(s) (a competency paired with a course, or several pairs added at the same time). The form has a dropdown for the competency. I'm a little confused as how to do this.Some thoughts I had:
' Loop through the selected items in the list box and build a text string
If Me!Lstcourses.ItemsSelected.Count > 0 Then
For Each varItem In Me!Lstcourses.ItemsSelected
strCriteria = strCriteria & "tblcourses.courseid = " & Chr(34) & Me!Lstcourses.ItemData(varItem) & Chr(34) & "OR "
Next varItem
strCriteria = Left(strCriteria, Len(strCriteria) - 4)
' ok i think i'm setting the strCriteria above to tblcourses.courseid="#selected" or is this setting it to text??? i did get a type mismatch trying variations of this
Else
MsgBox "Select An Item From The List First"
Exit Sub
End If
strSQL = "INSERT INTO tblmatched [courseid, compid]
ok thats all i get thats of any use..
any help greatly appreciated