none
Text box control help RRS feed

  • Question

  •  

    I have a Access 2013 form with a bunch of Bound and unbound controls on it.  To abbreviate, I am only picturing two of them.

     

    The original values are values stored in a table and are bound to the field in the table.  I need to provide an interface to allow a user to input new values.  When the form loads, the new value, which is an unbound text box is filled in due to a default value property set to: “=[Forms]![Catalog Data Entry Form]![GTINNumber]” .  The user selects the record she or he wants to edit from the catalog Data entry form.  I want the default value to be that value since s/he may only need to change a single digit.

    This works good, s/he can edit the new value fine.

    Now the real problem comes in because they want each edit session, original value and new value stored in a log table.  So, what I am planning to do is store the original value and the new value in the log table along with other information i.e. date/time and who did the edit, then update the bound original value with the new value.  This works well except now they threw a monkey wrench at me.

    Once they get to this form from the summary form, they want a next record and previous record button so they don’t have to go back to the summary form.

    Private Sub Next_Record_Click()

          On Error GoTo Done

          DoCmd.GoToRecord acDataForm, "Catalog data entry form", acNext

         Me.Requery

    Done:

    End Sub


     

    Private Sub PreviousRecord_Click()

     On Error GoTo Done

        DoCmd.GoToRecord acDataForm, "Catalog data entry form", acPrevious

        Me.Requery

    Done:  

    End Sub

     

    This works fine, except the default valuesIn the new values column are from the record I was just on when the form loaded.  So, I took the default values away from the unbound control.  The unbound controls can be edited at will.  However, I want to place the current original value into that control to save keystrokes.

    So, I created a got focus event for the unbound field. 

    Private Sub NEWGTINNUMBER_GotFocus()

         Me.new_GTIN_nuMBER = Me.GTINNumber

    End Sub

    My thought would be that when the user set the focus to that control, the Value would appear and s/he could edit it at will.  It doesn’t work.  I tried it with the on click event too.  I get this message.

    It doesn’t like “Me.new_GTIN_nuMBER = Me.GTINNumber”

    I also tried “Me.new_GTIN_nuMBER  = [Forms]![Catalog Data Entry Form]![GTINNumber]”

    I don’t understand why this won’t work.  What am I doing wrong?

     

    Friday, September 2, 2016 4:12 PM

Answers

  • So, I created a got focus event for the unbound field. 

    Private Sub NEWGTINNUMBER_GotFocus()

         Me.new_GTIN_nuMBER = Me.GTINNumber

    End Sub

    My thought would be that when the user set the focus to that control, the Value would appear and s/he could edit it at will.  It doesn’t work.  I tried it with the on click event too.  I get this message.

    It doesn’t like “Me.new_GTIN_nuMBER = Me.GTINNumber”

    I also tried “Me.new_GTIN_nuMBER  = [Forms]![Catalog Data Entry Form]![GTINNumber]”

    I don’t understand why this won’t work.  What am I doing wrong?

    It looks to me like "new_GTIN_NuMBer" isn't the name of the control.  Judging by the name of the event procedure, isn't the control named "NEWGTINNUMBER"?


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    • Marked as answer by tkosel Friday, September 2, 2016 4:41 PM
    Friday, September 2, 2016 4:20 PM

All replies

  • So, I created a got focus event for the unbound field. 

    Private Sub NEWGTINNUMBER_GotFocus()

         Me.new_GTIN_nuMBER = Me.GTINNumber

    End Sub

    My thought would be that when the user set the focus to that control, the Value would appear and s/he could edit it at will.  It doesn’t work.  I tried it with the on click event too.  I get this message.

    It doesn’t like “Me.new_GTIN_nuMBER = Me.GTINNumber”

    I also tried “Me.new_GTIN_nuMBER  = [Forms]![Catalog Data Entry Form]![GTINNumber]”

    I don’t understand why this won’t work.  What am I doing wrong?

    It looks to me like "new_GTIN_NuMBer" isn't the name of the control.  Judging by the name of the event procedure, isn't the control named "NEWGTINNUMBER"?


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    • Marked as answer by tkosel Friday, September 2, 2016 4:41 PM
    Friday, September 2, 2016 4:20 PM
  • Dirk,

    Good catch!!   I think I need to concentrate and improve on my naming conventions!  That was it, thanks again.

    Friday, September 2, 2016 4:41 PM