In the following snippet, before Else works fine. You'll remember helping me with interating through a list box. However, after Else fails to pick up the value in Me!CRN. In other words, the new record is added, all the values are entered from the text or combo boxes as indicated except for one, Me!CRN. I cannot see what I am missing.
Could this have anything to do with the name of the text box being the same as the table field name?
'Adding or changing the instructor name
If Me!cboInstr2 <> "" And Me!cboInstr2.Column(1) <> "STAFF" Then
rs.FindFirst "Sess = '02' "
If rs.NoMatch Then
'The section is cross listed with other sections
If Me!XLst <> "" Or Not IsNull(Me!XLst) Then
For i = 0 To Me!lstCombSect.ListCount - 1
'add new record using CRNs from list box
rs.AddNew
rs!CRN = Me!lstCombSect.ItemData(i)
'add the rest of the record data from form fields
rs!InstrName = Me!cboInstr2
rs!LName = Me!cboInstr2.Column(1)
rs!FName = Me!cboInstr2.Column(2)
rs!PInd = ""
rs!Sess = "02"
rs!DivNum = Me!txtDivNum
rs!XLst = Me!XLst
rs.Update
Next i
Me!lstInstrName.Requery
'The section is not cross listed with other sections
Else
rs.AddNew
rs!CRN = Me!CRN
rs!InstrName = Me!cboInstr2
rs!LName = Me!cboInstr2.Column(1)
rs!FName = Me!cboInstr2.Column(2)
rs!PInd = ""
rs!Sess = "02"
rs!DivNum = Me!txtDivNum
rs!XLst = ""
rs.Update
Me!lstInstrName.Requery
End If
[more code after this not included here]
Could this have anything to do with the name of the text box being the same as the table field name?
'Adding or changing the instructor name
If Me!cboInstr2 <> "" And Me!cboInstr2.Column(1) <> "STAFF" Then
rs.FindFirst "Sess = '02' "
If rs.NoMatch Then
'The section is cross listed with other sections
If Me!XLst <> "" Or Not IsNull(Me!XLst) Then
For i = 0 To Me!lstCombSect.ListCount - 1
'add new record using CRNs from list box
rs.AddNew
rs!CRN = Me!lstCombSect.ItemData(i)
'add the rest of the record data from form fields
rs!InstrName = Me!cboInstr2
rs!LName = Me!cboInstr2.Column(1)
rs!FName = Me!cboInstr2.Column(2)
rs!PInd = ""
rs!Sess = "02"
rs!DivNum = Me!txtDivNum
rs!XLst = Me!XLst
rs.Update
Next i
Me!lstInstrName.Requery
'The section is not cross listed with other sections
Else
rs.AddNew
rs!CRN = Me!CRN
rs!InstrName = Me!cboInstr2
rs!LName = Me!cboInstr2.Column(1)
rs!FName = Me!cboInstr2.Column(2)
rs!PInd = ""
rs!Sess = "02"
rs!DivNum = Me!txtDivNum
rs!XLst = ""
rs.Update
Me!lstInstrName.Requery
End If
[more code after this not included here]