Help with writing to a linked table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • troy_lee@comcast.net

    Help with writing to a linked table

    I have a linked table (two primary keys: one coming from Me.txtRMA#
    and the other is an Autonumber) that I am writing to from an unbound
    form. Please review my code and tell me what is wrong with it. I don't
    get any errors and no data is written to the table. It doesn't do
    anything. Thanks for the help

    Private Sub cmdSubmit_Click ()
    On Error GoTo Submit_Click_Er r
    Dim rstEvalForm As Recordset

    'Set the variable by opening the Table: tblRMAEval.
    Set rstEvalForm = CurrentDb.OpenR ecordset("tblRM AEval", dbOpenDynaset)
    With rstEvalForm
    'Add a new record to the end of the Recordset Object.
    .AddNew
    ![idsRMA#] = Me.[txtRMA#]
    ![dtmDate] = Me.cboEvalDate
    ![chrTech] = Me.cboTechName
    ![blnLooseHardwar eCheck] = Me.chkHardware
    ![blnWiringConnec tionsCheck] = Me.chkWiring
    ![blnOpticsCheck] = Me.chkOptical
    ![chrVisualCommen ts] = Me.txtVisualCom ments
    ![blnShortsCheck] = Me.chkShorts
    ![chrShotsCount] = Me.txtShots
    ![intInputE] = Me.txtInputE
    ![intDoubleE] = Me.txtDoubleE
    ![intPFNE] = Me.txtPFNE
    ![intSCRE] = Me.txtSCRE
    ![chrPowerComment s] = Me.txtPowerComm ents
    ![blnLaserFire] = Me.chkFired
    ![int10ShotAvg] = Me.txt10Shot
    ![intPW] = Me.txtPW
    ![blnATREnergy] = Me.chkATR
    ![blnGUITest] = Me.chkGUI
    ![chrLaserComment s] = Me.txtLaserComm ents
    ![intFirstTargetA ctual] = Me.txtFirstBIT
    ![intLastTargetAc tual] = Me.txtLastBIT
    .Update
    End With
    'Close the recordset and set it to nothing.
    rstEvalForm.Clo se
    Set rstEvalForm = Nothing

    cmdSubmit_Click _Exit:
    ExitSub
    cmdSubmit_Click _Err:
    MsgBox Err.Description
    Resume cmdSubmit_Click _Err
    End Sub

    Thanks in advance.

    Troy Lee
  • Keith Wilby

    #2
    Re: Help with writing to a linked table

    <troy_lee@comca st.netwrote in message
    news:31222451-b4e1-43c1-8aa0-1fe4415a0ba7@a7 0g2000hsh.googl egroups.com...
    ![idsRMA#] = Me.[txtRMA#]
    ![idsRMA#] = Me.txtRMA#

    Maybe? Not sure that using # in a field name is a good thing.

    Regards,
    Keith.


    Comment

    • Bruce

      #3
      Re: Help with writing to a linked table

      On Jul 30, 7:13 am, troy_...@comcas t.net wrote:
      I have a linked table (two primary keys: one coming from Me.txtRMA#
      and the other is an Autonumber) that I am writing to from an unbound
      form. Please review my code and tell me what is wrong with it. I don't
      get any errors and no data is written to the table. It doesn't do
      anything. Thanks for the help
      >
      Private Sub cmdSubmit_Click ()
      On Error GoTo Submit_Click_Er r
      Dim rstEvalForm As Recordset
      >
      'Set the variable by opening the Table: tblRMAEval.
      Set rstEvalForm = CurrentDb.OpenR ecordset("tblRM AEval", dbOpenDynaset)
          With rstEvalForm
              'Add a new record to the end of the Recordset Object.
              .AddNew
              ![idsRMA#] = Me.[txtRMA#]
              ![dtmDate] = Me.cboEvalDate
              ![chrTech] = Me.cboTechName
              ![blnLooseHardwar eCheck] = Me.chkHardware
              ![blnWiringConnec tionsCheck] = Me.chkWiring
              ![blnOpticsCheck] = Me.chkOptical
              ![chrVisualCommen ts] = Me.txtVisualCom ments
              ![blnShortsCheck] = Me.chkShorts
              ![chrShotsCount] = Me.txtShots
              ![intInputE] = Me.txtInputE
              ![intDoubleE] = Me.txtDoubleE
              ![intPFNE] = Me.txtPFNE
              ![intSCRE] = Me.txtSCRE
              ![chrPowerComment s] = Me.txtPowerComm ents
              ![blnLaserFire] = Me.chkFired
              ![int10ShotAvg] = Me.txt10Shot
              ![intPW] = Me.txtPW
              ![blnATREnergy] = Me.chkATR
              ![blnGUITest] = Me.chkGUI
              ![chrLaserComment s] = Me.txtLaserComm ents
              ![intFirstTargetA ctual] = Me.txtFirstBIT
              ![intLastTargetAc tual] = Me.txtLastBIT
              .Update
          End With
      'Close the recordset and set it to nothing.
      rstEvalForm.Clo se
      Set rstEvalForm = Nothing
      >
      cmdSubmit_Click _Exit:
          ExitSub
      cmdSubmit_Click _Err:
          MsgBox Err.Description
          Resume cmdSubmit_Click _Err
      End Sub
      >
      Thanks in advance.
      >
      Troy Lee
      I know this code isn't exactly as you are running it because you'd get
      a compile error saying "label not defined". Your 'On Error' statement
      points to a non-existent line label. There is no "Submit_Click_E rr"
      line, but there is a "cmdSubmit_Clic k_Err" line. After that, your
      Resume will send you into an infinite loop (you probably meant to say
      "resume cmdSubmit_Click _Exit"

      Bruce

      Comment

      • troy_lee@comcast.net

        #4
        Re: Help with writing to a linked table

        On Jul 30, 1:07 pm, Bruce <deluxeinformat ...@gmail.comwr ote:
        On Jul 30, 7:13 am, troy_...@comcas t.net wrote:
        >
        >
        >
        I have a linked table (two primary keys: one coming from Me.txtRMA#
        and the other is an Autonumber) that I am writing to from an unbound
        form. Please review my code and tell me what is wrong with it. I don't
        get any errors and no data is written to the table. It doesn't do
        anything. Thanks for the help
        >
        Private Sub cmdSubmit_Click ()
        On Error GoTo Submit_Click_Er r
        Dim rstEvalForm As Recordset
        >
        'Set the variable by opening the Table: tblRMAEval.
        Set rstEvalForm = CurrentDb.OpenR ecordset("tblRM AEval", dbOpenDynaset)
        With rstEvalForm
        'Add a new record to the end of the Recordset Object.
        .AddNew
        ![idsRMA#] = Me.[txtRMA#]
        ![dtmDate] = Me.cboEvalDate
        ![chrTech] = Me.cboTechName
        ![blnLooseHardwar eCheck] = Me.chkHardware
        ![blnWiringConnec tionsCheck] = Me.chkWiring
        ![blnOpticsCheck] = Me.chkOptical
        ![chrVisualCommen ts] = Me.txtVisualCom ments
        ![blnShortsCheck] = Me.chkShorts
        ![chrShotsCount] = Me.txtShots
        ![intInputE] = Me.txtInputE
        ![intDoubleE] = Me.txtDoubleE
        ![intPFNE] = Me.txtPFNE
        ![intSCRE] = Me.txtSCRE
        ![chrPowerComment s] = Me.txtPowerComm ents
        ![blnLaserFire] = Me.chkFired
        ![int10ShotAvg] = Me.txt10Shot
        ![intPW] = Me.txtPW
        ![blnATREnergy] = Me.chkATR
        ![blnGUITest] = Me.chkGUI
        ![chrLaserComment s] = Me.txtLaserComm ents
        ![intFirstTargetA ctual] = Me.txtFirstBIT
        ![intLastTargetAc tual] = Me.txtLastBIT
        .Update
        End With
        'Close the recordset and set it to nothing.
        rstEvalForm.Clo se
        Set rstEvalForm = Nothing
        >
        cmdSubmit_Click _Exit:
        ExitSub
        cmdSubmit_Click _Err:
        MsgBox Err.Description
        Resume cmdSubmit_Click _Err
        End Sub
        >
        Thanks in advance.
        >
        Troy Lee
        >
        I know this code isn't exactly as you are running it because you'd get
        a compile error saying "label not defined". Your 'On Error' statement
        points to a non-existent line label. There is no "Submit_Click_E rr"
        line, but there is a "cmdSubmit_Clic k_Err" line. After that, your
        Resume will send you into an infinite loop (you probably meant to say
        "resume cmdSubmit_Click _Exit"
        >
        Bruce
        Thank you. Good catch. I will give it a try.

        Troy

        Comment

        Working...