Retain fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pukhton
    New Member
    • Jun 2007
    • 75

    Retain fields

    HI Folks,

    I have a question. On one of my Access form, I want to retain some certain fileds (Like name, ID etc) in the form, when user click ot add a new record?
    I want to show name, ID # to be transfred to the next record, where user dont have to enter username and ID over and over.

    If its a new name and new ID, then user can delte that and enter a new info, and this new name will carryover to the new record.

    I hope i explained my question....... ..

    please help me..
    Thx
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    You need to assign the fields you want to carry forward to their individual DefaultValues in their AfterUpdate events. The syntax varies according to their datatype.

    For Text fields

    Code:
    Private Sub YourTextControlName_AfterUpdate()
    If Not IsNull(Me.YourTextControlName.Value) Then
      YourTextControlName.DefaultValue = """" & Me.YourTextControlName.Value & """"
    End If
    End Sub
    For Numeric fields

    Code:
    Private Sub YourNumericControlName_AfterUpdate()
    If Not IsNull(Me.YourNumericControlName.Value) Then
      YourNumericControlName.DefaultValue = Me.YourNumericControlName.Value
    End If
    End Sub
    For Date fields

    Code:
    Private Sub YourDateControlName_AfterUpdate()
    If Not IsNull(Me.YourDateControlName.Value) Then
      YourDateControlName.DefaultValue ="#" &  Me.YourDateControlName & "#"
    End If
    End Sub
    Linq ;0)>

    Comment

    • pukhton
      New Member
      • Jun 2007
      • 75

      #3
      Great...It worked...

      Thanks for your help

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        Glad we could help!

        Linq ;0)>

        Comment

        • pukhton
          New Member
          • Jun 2007
          • 75

          #5
          All the other fields are working expect the date field.
          Any idea why?

          [CODE=vb]

          Private Sub Date_AfterUpdat e()
          If Not IsNull(Me.Date. Value) Then
          Date.DefaultVal ue = "#" & Me.Date & "#"
          End If

          End Sub

          [/CODE]

          Comment

          • pukhton
            New Member
            • Jun 2007
            • 75

            #6
            Can someone please explain why my date field is not WORKING? I tried every single thing...



            Originally posted by pukhton
            All the other fields are working expect the date field.
            Any idea why?

            [CODE=vb]

            Private Sub Date_AfterUpdat e()
            If Not IsNull(Me.Date. Value) Then
            Date.DefaultVal ue = "#" & Me.Date & "#"
            End If

            End Sub

            [/CODE]

            Comment

            • missinglinq
              Recognized Expert Specialist
              • Nov 2006
              • 3533

              #7
              Date is an Access Reserved Word and a very special one! It should never be used as an object name! Change your textbox named Date to something else, like txtDate, then check your systems's date! Take a peek here for the reason why:



              Linq ;0)>

              Comment

              Working...