When you say it's an Autonumber field, do you mean the built-in Autonumber
data type, or is it a "roll-your-own" version of Autonumber?
The built-in Access Autonumber value is generated when you first "touch" the
row, before you save it, so I don't see how you could possibly be getting a
Null-related error related to it.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
>I have a custom entry form that keeps producing a error saying that the
>index
[quoted text clipped - 3 lines]
> index prior to updating so that I no longer get the error saying that the
> index is null?
Cameron - 05 Mar 2007 22:08 GMT
This is the code I have for the click event that is giving me trouble.
Private Sub MoveToAttendees_Click()
On Error GoTo MoveToAttendeesError
Dim MyDB As Database
Dim MyStudents As Recordset
Dim MySessions As Recordset
Dim I, X As Integer
Dim MyCriteria As String
Set MyDB = CurrentDb
Set MyStudents = MyDB.OpenRecordset("SessionAttendance")
DoCmd.Hourglass True
For I = 0 To Me.EmployeesList.ListCount
'MsgBox "on item # " & I
If Me!EmployeesList.Selected(I) = True Then
With MyStudents
.AddNew
!CourseID = Me.CourseID
!SessionID = Me.SessionID
!EmpID = Me.EmployeesList.ItemData(I)
!Attended = True
.Update
End With
End If
Next I
MyStudents.Close
MyDB.Close
Set MyDB = Nothing
Form.Refresh
DoCmd.Hourglass False
Me.MoveToAttendees.DefaultValue = False
DisplayEmailButton
Exit Sub
MoveToAttendeesError:
If err.Number = 3022 Then 'Duplicate record
MsgBox "The employee '" & Me!EmployeesList.Column(2, I) & " " &
Me!EmployeesList.Column(1, I) & _
"' is already attending this session."
Else
MsgBox Error$ & err.Number
End If
MyStudents.Close
MyDB.Close
Set MyDB = Nothing
DoCmd.Hourglass False
Me.MoveToAttendees.DefaultValue = False
End Sub
Where it calls the sessionID it pulls a null value from the SessionID
textbox which is a autonumber field in the table. So I need a way for that
textbox to actually have a value in it. It isn't filling the value.
> When you say it's an Autonumber field, do you mean the built-in Autonumber
> data type, or is it a "roll-your-own" version of Autonumber?
[quoted text clipped - 10 lines]
> > index prior to updating so that I no longer get the error saying that the
> > index is null?