Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2007

Tip: Looking for answers? Try searching our database.

Null error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cameron - 05 Mar 2007 19:44 GMT
I have a custom entry form that keeps producing a error saying that the index
can not be null. The index is assigned to an autonumber field and during
processing of the form the autonumber field doesn't have a value until the
record gets saved. Is there a way to have the autonumber field generate an
index prior to updating so that I no longer get the error saying that the
index is null?
Douglas J. Steele - 05 Mar 2007 19:49 GMT
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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.