• Carry Forward Selected Values to Next Record Access 2010 32bit

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Carry Forward Selected Values to Next Record Access 2010 32bit

    Author
    Topic
    #480048

    I have a data input form for transactions. The form has a button to create additional transactions for the same customer. Basic information would be the same on that next transaction (for example, account office and approval date).

    That button saves the current record and creates a new one. How can I carry forward the selected fields to that new record? I tried the code below, but it is not working. This is in the AfterUpdate event.

    DoCmd.RunCommand acCmdSaveRecord
    Dim ctl As Control
    For Each ctl In Me.Controls
    If ctl.Tag = “CarryForward” Then
    ctl.DefaultValue = “””” & ctl.Value & “”””
    End If
    Next ctl

    I entered CarryForward into the tag property for the fields I want carried forward.

    Behind the command button to create the new record, it just has DoCmd.GoToRecord , , acNewRec

    Thank you for any suggestions.

    Nancy

    Viewing 0 reply threads
    Author
    Replies
    • #1306756

      I have a data input form for transactions. The form has a button to create additional transactions for the same customer. Basic information would be the same on that next transaction (for example, account office and approval date).

      That button saves the current record and creates a new one. How can I carry forward the selected fields to that new record? I tried the code below, but it is not working. This is in the AfterUpdate event.

      DoCmd.RunCommand acCmdSaveRecord
      Dim ctl As Control
      For Each ctl In Me.Controls
      If ctl.Tag = “CarryForward” Then
      ctl.DefaultValue = “””” & ctl.Value & “”””
      End If
      Next ctl

      I entered CarryForward into the tag property for the fields I want carried forward.

      Behind the command button to create the new record, it just has DoCmd.GoToRecord , , acNewRec

      Thank you for any suggestions.

      Nancy

      For one thing, you are making all the Default Values a text string, which may not be applicable to the particular field. For example, if it is a Date field, your default value should use # and not quotes; that is, the end result should be #11/15/11# and not “11/15/11”. In your code, you might want to examine the Data Type to determine how to form the Default Value. Either that or have different Tags, such as “CarryForwardDate”, and then act accordingly.

      And here is a tip, seeing “””” is nearly impossible to read, and easy to make a mistake. If you want to embed a quote mark use chr(34) so it would look like this: ctl.DefaultValue = chr(34) & ctl.Value & chr(34)

      Or, you can create your own function which can be used anywhere. I use Qu() so I can write: ctl.DefaultValue = Qu() & ctl.Value & Qu()
      Easy to read, hard to make a mistake.

      In any module, put:

      Public Function Qu() as String[INDENT]Qu() = chr(34)[/INDENT]
      End Function

    Viewing 0 reply threads
    Reply To: Carry Forward Selected Values to Next Record Access 2010 32bit

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: