Trapping/disabling runtime error 30014

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Armstrong

    Trapping/disabling runtime error 30014

    Hello all -

    This is driving me crazy. I have a table called tblClients - very
    simple, has the following fields:

    taxID (PK)
    ClientName
    SalesName

    The main form of my application allows a user to select a client and
    shows sales transactions on a subform. I wanted to include a button
    the user could click which would allow them to edit the client
    information. So, I created a form called frmEditClient which is loaded
    when the button is clicked. Code on the OnClick event for the code
    button:

    Private Sub cmdEditClient_C lick()
    Dim LinkCriteria As String
    LinkCriteria = "[ClientName]= '" & Me.txtSelectedC Lient & "'"
    DoCmd.OpenForm "frmEditClient" , , , LinkCriteria
    End Sub

    Pretty simple, just opens the EditClient form using the current client
    in the recordsource - this opens the form and the user can edit
    details and save the form. The recordsource of frmEditClient is a
    query called vwEditClient that selects all from tblClients (tried
    using tblClients as record source - same problem)

    Only problem is if the user wants to edit the ClientName field - since
    frmEditClient is using the ClientName field as a filter, I get a
    runtime error 30014 - the data has been added but cannot be displayed
    because it no longer meets the criteria of the underlying
    recordsource.

    I know *why* I'm getting the error, I just want to stop it. I've tried
    to trap the damn thing, but can't seem to get it to trap - the error
    is generated on the "me.dirty=false " line, and this stops any code
    after from running. I have tried to put On Error Goto 0 at the
    beginning of the sub, etc..., but nothing seems to trigger.

    Here is the code for the Save button, without any error handling:

    Private Sub cmdSave_Click()
    If Me.Dirty Then
    Me.Dirty = False
    Else
    MsgBox ("No changes were detected - please make your changes, or
    hit Cancel to return to the previous screen")
    Exit Sub
    End If
    DoCmd.Close acForm, "frmEditCli ent"
    End Sub

    All I want is:

    1) A way to load the frmEditClient so the form displays the client
    that was selected on the main form
    2) A way to suppress or hide the runtime error that occurs when the
    user edits the clientname.

    Can someone assist with a way to trap this error or prevent it from
    happening?

    Thanks
  • Jim Armstrong

    #2
    Re: Trapping/disabling runtime error 30014

    On May 5, 3:38 pm, Jim Armstrong <armstron...@ho tmail.comwrote:
    Hello all -
    >
    This is driving me crazy. I have a table called tblClients - very
    simple, has the following fields:
    >
    taxID (PK)
    ClientName
    SalesName
    >
    The main form of my application allows a user to select a client and
    shows sales transactions on a subform. I wanted to include a button
    the user could click which would allow them to edit the client
    information. So, I created a form called frmEditClient which is loaded
    when the button is clicked. Code on the OnClick event for the code
    button:
    >
    Private Sub cmdEditClient_C lick()
    Dim LinkCriteria As String
    LinkCriteria = "[ClientName]= '" & Me.txtSelectedC Lient & "'"
    DoCmd.OpenForm "frmEditClient" , , , LinkCriteria
    End Sub
    >
    Pretty simple, just opens the EditClient form using the current client
    in the recordsource - this opens the form and the user can edit
    details and save the form. The recordsource of frmEditClient is a
    query called vwEditClient that selects all from tblClients (tried
    using tblClients as record source - same problem)
    >
    Only problem is if the user wants to edit the ClientName field - since
    frmEditClient is using the ClientName field as a filter, I get a
    runtime error 30014 - the data has been added but cannot be displayed
    because it no longer meets the criteria of the underlying
    recordsource.
    >
    I know *why* I'm getting the error, I just want to stop it. I've tried
    to trap the damn thing, but can't seem to get it to trap - the error
    is generated on the "me.dirty=false " line, and this stops any code
    after from running. I have tried to put On Error Goto 0 at the
    beginning of the sub, etc..., but nothing seems to trigger.
    >
    Here is the code for the Save button, without any error handling:
    >
    Private Sub cmdSave_Click()
    If Me.Dirty Then
        Me.Dirty = False
    Else
        MsgBox ("No changes were detected - please make your changes, or
    hit Cancel to return to the previous screen")
        Exit Sub
    End If
    DoCmd.Close acForm, "frmEditCli ent"
    End Sub
    >
    All I want is:
    >
    1) A way to load the frmEditClient so the form displays the client
    that was selected on the main form
    2) A way to suppress or hide the runtime error that occurs when the
    user edits the clientname.
    >
    Can someone assist with a way to trap this error or prevent it from
    happening?
    >
    Thanks
    Well, I still have not been able to trap the error, but I was able to
    get around it using the resync property. Basically, I added the
    following line in the Save button's On Click code:

    Me.ResyncComman d = "SELECT * FROM vwEditClient WHERE TaxID=?"

    Seems to work so far - but I'm still all ears if anyone has some
    trapping code I could try or a reason the 30014 runtime was not picked
    up by my attempts...

    Thanks!

    Comment

    • Salad

      #3
      Re: Trapping/disabling runtime error 30014

      Jim Armstrong wrote:
      On May 5, 3:38 pm, Jim Armstrong <armstron...@ho tmail.comwrote:
      >
      >>Hello all -
      >>
      >>This is driving me crazy. I have a table called tblClients - very
      >>simple, has the following fields:
      >>
      >>taxID (PK)
      >>ClientName
      >>SalesName
      >>
      >>The main form of my application allows a user to select a client and
      >>shows sales transactions on a subform. I wanted to include a button
      >>the user could click which would allow them to edit the client
      >>information . So, I created a form called frmEditClient which is loaded
      >>when the button is clicked. Code on the OnClick event for the code
      >>button:
      >>
      >>Private Sub cmdEditClient_C lick()
      >>Dim LinkCriteria As String
      >>LinkCriteri a = "[ClientName]= '" & Me.txtSelectedC Lient & "'"
      >>DoCmd.OpenFor m "frmEditClient" , , , LinkCriteria
      >>End Sub
      >>
      >>Pretty simple, just opens the EditClient form using the current client
      >>in the recordsource - this opens the form and the user can edit
      >>details and save the form. The recordsource of frmEditClient is a
      >>query called vwEditClient that selects all from tblClients (tried
      >>using tblClients as record source - same problem)
      >>
      >>Only problem is if the user wants to edit the ClientName field - since
      >>frmEditClie nt is using the ClientName field as a filter, I get a
      >>runtime error 30014 - the data has been added but cannot be displayed
      >>because it no longer meets the criteria of the underlying
      >>recordsourc e.
      >>
      >>I know *why* I'm getting the error, I just want to stop it. I've tried
      >>to trap the damn thing, but can't seem to get it to trap - the error
      >>is generated on the "me.dirty=false " line, and this stops any code
      >>after from running. I have tried to put On Error Goto 0 at the
      >>beginning of the sub, etc..., but nothing seems to trigger.
      >>
      >>Here is the code for the Save button, without any error handling:
      >>
      >>Private Sub cmdSave_Click()
      >>If Me.Dirty Then
      > Me.Dirty = False
      >>Else
      > MsgBox ("No changes were detected - please make your changes, or
      >>hit Cancel to return to the previous screen")
      > Exit Sub
      >>End If
      >>DoCmd.Close acForm, "frmEditCli ent"
      >>End Sub
      >>
      >>All I want is:
      >>
      >>1) A way to load the frmEditClient so the form displays the client
      >>that was selected on the main form
      >>2) A way to suppress or hide the runtime error that occurs when the
      >>user edits the clientname.
      >>
      >>Can someone assist with a way to trap this error or prevent it from
      >>happening?
      >>
      >>Thanks
      >
      >
      Well, I still have not been able to trap the error, but I was able to
      get around it using the resync property. Basically, I added the
      following line in the Save button's On Click code:
      >
      Me.ResyncComman d = "SELECT * FROM vwEditClient WHERE TaxID=?"
      >
      Seems to work so far - but I'm still all ears if anyone has some
      trapping code I could try or a reason the 30014 runtime was not picked
      up by my attempts...
      >
      Thanks!
      There's on OnError event for the form. It's not a runtime VBA error. So
      perhaps that's where that error is being generated. If so, in the error
      routine try entering
      If DataErr = 30014 then response = acdataerrcontin ue

      Amore

      Comment

      • diogenes

        #4
        Re: Trapping/disabling runtime error 30014

        Jim Armstrong <armstrongjc@ho tmail.comwrote in news:0c3890c4-9c48-4d54-
        96f9-1f7e236804d2@b6 4g2000hsa.googl egroups.com:
        On May 5, 3:38 pm, Jim Armstrong <armstron...@ho tmail.comwrote:
        >Hello all -
        >>
        >This is driving me crazy. I have a table called tblClients - very
        >simple, has the following fields:
        >>
        >taxID (PK)
        >ClientName
        >SalesName
        >>
        >The main form of my application allows a user to select a client and
        >shows sales transactions on a subform. I wanted to include a button
        >the user could click which would allow them to edit the client
        >information. So, I created a form called frmEditClient which is loaded
        >when the button is clicked. Code on the OnClick event for the code
        >button:
        >>
        >Private Sub cmdEditClient_C lick()
        >Dim LinkCriteria As String
        >LinkCriteria = "[ClientName]= '" & Me.txtSelectedC Lient & "'"
        >DoCmd.OpenFo rm "frmEditClient" , , , LinkCriteria
        >End Sub
        >>
        >Pretty simple, just opens the EditClient form using the current client
        >in the recordsource - this opens the form and the user can edit
        >details and save the form. The recordsource of frmEditClient is a
        >query called vwEditClient that selects all from tblClients (tried
        >using tblClients as record source - same problem)
        >>
        >Only problem is if the user wants to edit the ClientName field - since
        >frmEditClien t is using the ClientName field as a filter, I get a
        >runtime error 30014 - the data has been added but cannot be displayed
        >because it no longer meets the criteria of the underlying
        >recordsource .
        >>
        >I know *why* I'm getting the error, I just want to stop it. I've tried
        >to trap the damn thing, but can't seem to get it to trap - the error
        >is generated on the "me.dirty=false " line, and this stops any code
        >after from running. I have tried to put On Error Goto 0 at the
        >beginning of the sub, etc..., but nothing seems to trigger.
        >>
        >Here is the code for the Save button, without any error handling:
        >>
        >Private Sub cmdSave_Click()
        >If Me.Dirty Then
        >    Me.Dirty = False
        >Else
        >    MsgBox ("No changes were detected - please make your changes, or
        >hit Cancel to return to the previous screen")
        >    Exit Sub
        >End If
        >DoCmd.Close acForm, "frmEditCli ent"
        >End Sub
        >>
        >All I want is:
        >>
        >1) A way to load the frmEditClient so the form displays the client
        >that was selected on the main form
        >2) A way to suppress or hide the runtime error that occurs when the
        >user edits the clientname.
        >>
        >Can someone assist with a way to trap this error or prevent it from
        >happening?
        >>
        >Thanks
        >
        Well, I still have not been able to trap the error, but I was able to
        get around it using the resync property. Basically, I added the
        following line in the Save button's On Click code:
        >
        Me.ResyncComman d = "SELECT * FROM vwEditClient WHERE TaxID=?"
        >
        Seems to work so far - but I'm still all ears if anyone has some
        trapping code I could try or a reason the 30014 runtime was not picked
        up by my attempts...
        >
        Thanks!
        Try using On Error Resume Next just prior to the Me.Dirty = False
        statement. That should let you then examine the Err.Number (if 13004,
        resume, if anything else do something).

        Do you have Error Handling set to Break on Unhandled Errors?

        You can't trap an error AS it is happening, you can only respond to it
        after the fact.

        The reason you're having so much trouble is that it is the equivalent of
        sawing off the branch while standing on it. As soon as you change the
        ClientName, the record *should* vanish (since it is not within the filter
        criteria. Access detects this as a logical impossibility and throws the
        error.

        Instead, you might try declaring a Public string variable in the module
        area of the original form. Store the original value of ClientName. Open
        frmEditClient as a dialog (acDialog) and when you close frmEditClient,
        store the new value into the Public variable. Then compare the ClientName
        textbox value with the Public variable. If different, replace ClientName
        with the new value.



        Comment

        Working...