Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2006
    Posts
    30

    Exclamation Unanswered: Help! Getting Error 2499 Cant Use GoToRecord In Design View!

    Hi Guys,

    RE: Access 2000

    I assume that this error has cropped up in these forums a few times before but i can't seem to find it.
    I have a bit of code which checks the fields on a form using the beforeupdate method and validates the results. If contents are correct the file saves. if not the incorrect fields are highlighted in red.
    At the moment the incorrect entries are being highlighted but when i enter in a record without ant errors the navigation buttons don't respond (i.s previous & next buttons don't do anything and record remains on screen).
    I have an error handler which catches a few error types and ignores them but when i debug the code i get the error 'runtime error 2499: cant use the gotorecord method in design view'.
    What does that mean? i'm not using it in design view! it is just the wizard-created navigation buttons. Code is as follows:

    The beforeUpdate runs this code to validate fields in the form. The cmdNext button code is also show at the bottom:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    
        
    
        Dim intCancelUpdateCount As Integer
    
        Dim strReferralMsg As String
    
        
    
        strReferralMsg = "Data Entry Errors Detected!" & vbCrLf & "Please correct the data making sure all required fields have a value entered" & vbCrLf & "Please correct all the fields highlighted in red!"
    
        ClearValidationHighlight Me
    
    'count value returned by validation code (0 no error, 1 error for each field)
    
        intCancelUpdateCount = intCancelUpdateCount + ValidateRequiredFields(Me.strChair, strReferralMsg)
    
        intCancelUpdateCount = intCancelUpdateCount + ValidateRequiredFields(Me.strMemeber1, strReferralMsg)
    
        intCancelUpdateCount = intCancelUpdateCount + ValidateRequiredFields(Me.strMember2, strReferralMsg)
    
        intCancelUpdateCount = intCancelUpdateCount + ValidateRequiredFields(Me.strReserve1, strReferralMsg)
    
        intCancelUpdateCount = intCancelUpdateCount + ValidateRequiredFields(Me.strSecretary, strReferralMsg)
    
        intCancelUpdateCount = intCancelUpdateCount + ValidateRequiredFields(Me.dtmDateOfCommitteeMeeting, strReferralMsg)
    
        intCancelUpdateCount = intCancelUpdateCount + ValidateRequiredFields(Me.strTimePeriod, strReferralMsg)
    
        intCancelUpdateCount = intCancelUpdateCount + ValidateRequiredFields(Me.strVenue, strReferralMsg)
    
    
    
        If intCancelUpdateCount = 0 Then
    
            Cancel = False
    
            Exit Sub
    
        End If
    
        
    
        MsgBox strReferralMsg, vbExclamation + vbOKOnly, "Errors Detected"
    
        Cancel = True 
    
        
    
        
    
    End Sub
    
    
    
    
    
    
    
    Public Function ValidateRequiredFields(ctlRequiredField As Control, Optional strMsg As String) As Integer
    
        
    
        ctlRequiredField.SetFocus
    
        If IsNull(ctlRequiredField) Or (Len(ctlRequiredField) < 1) Then
    
            If strMsg = "" Then
    
                MsgBox "Data Entry Errors Detected!" & vbCrLf & "Please correct the data making sure all required fields have a value entered", vbExclamation + vbOKOnly, "Errors Detected!"
    
            End If
    
            ctlRequiredField.SpecialEffect = 0
    
            ctlRequiredField.BorderColor = vbRed
    
            'set numeric value to this function
    
            ValidateRequiredFields = VALIDATION_FALSE
    
        Else
    
            ValidateRequiredFields = VALIDATION_TRUE
    
        End If
    
        
    
    End Function
    
    
    
    
    
    'clears any highlighted error fields
    
    Public Sub ClearValidationHighlight(frmForm As Form)
    
        
    
        Dim ctl As Object
    
        
    
        For Each ctl In frmForm.Controls
    
            If TypeOf ctl Is TextBox Then
    
                If ctl.Name <> "lblRecCount" Then
    
                    ctl.SpecialEffect = 3
    
                End If
    
            ElseIf TypeOf ctl Is ComboBox Then
    
                ctl.SpecialEffect = 3
    
            End If
    
        Next
    
        
    
    End Sub
    
    
    
    
    
    
    
    Private Sub cmdNextRec_Click()
    
    On Error GoTo Err_cmdNextRec_Click
    
    
    
        DoCmd.GoToRecord , , acNext
    
    
    
    Exit_cmdNextRec_Click:
    
        Exit Sub
    
    
    
    Err_cmdNextRec_Click:
    
    
    
        If (Err.Number = 2105) And (Me.NewRecord) And (Me.Dirty) Then
    
            Resume Exit_cmdNextRec_Click
    
        Else
    
            ErrorEnd Me.Name, Me.ActiveControl.Name, Err
    
            Resume Exit_cmdNextRec_Click
    
        End If
    
        
    
    End Sub

    This has been irratating me for days and i know i'm doing something stupid.
    Please help me and put me out of my misery.
    Any help would be greatly appreciated.

    Thank you in advance,

    Shuja.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Don't entirely follow your code but...
    Does your form have a control source?

    -GeorgeV
    George
    Home | Blog

  3. #3
    Join Date
    Sep 2006
    Posts
    30
    Hi Georgev,

    Yeah, the form does have a control source. It is a table.
    The idea behind the code was to replace the generic error msg thrown up by the wizard buttons (i.e. next previous etc) with a more specific one but also have a bit of code which validates the data in the record. If their is an error in the data (i.e. have not entered a value for a required field) then an error msg is thrown up & the field border is highlighted in red. This part works fine. It is when a record is created correctly (without errors) when my 2499 error pops up. It saves the record but does not move off the current record when i use any of the navigation buttons. When i debug the code i get the 2499 error msg.
    When i take the custom code out the form works properly using the validation set in the table but i need the code to be included.
    Any ideas what the problem might be?

    Thanks,

    Shuja.

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Any chance you can knock up a quick mbd and upload it so I can take a look?

    Try commenting out this line and running it again
    Code:
    ErrorEnd Me.Name, Me.ActiveControl.Name, Err
    Other than that all I can suggest at this stage is to step through the code stage by stage.

    - GeorgeV
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •