Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Feb 2001
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Value Previous Field? (Access 2000)

    Hi All!

    Working with a data entry form in Access 2000, and I'm trying to do something with a textbox I thought would be simple....

    I'd like to make the default value of the text box to be the previous record of that text box i.e. we may be entering the same supplier for 20 records in a row. Any ideas?

    Tim

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Default Value Previous Field? (Access 2000)

    There are a couple of ways to do it, but the simplest would probably be to use the AfterUpdate event of the textbox to set its defaultvalue property to the textbox's value. That way when you enter a new value, that will be stored in the defaultvalue property and should come up when you move to a new record. If you need detailed assistance, post back.
    Charlotte

  3. #3
    New Lounger
    Join Date
    Feb 2001
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Default Value Previous Field? (Access 2000)

    Thanks for your prompt reply--A nice elegant solution solution, which I sadly can't get to work. It's a combo box, and I'm putting [comboboxname].DefaultValue=[comboboxname].Text in the AfterUpdate property of the c-box. Even tried .Value. Nothing doing. Am I being a little oversimplistic?

    Tim

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Default Value Previous Field? (Access 2000)

    You're a bit astray - AfterUpdate is an event and it is expecting to see some code (or a macro or something like that). On the Data tab you should see a Default Value property as the third item down. You should be able to set it to the name of the text box.

    I have a broader question however. It sounds as though your table may not be normalized - that is you are storing all of the supplier details in every record. This is where relational databases shine. You have one supplier record, and lots of detail records which have a pointer to the supplier record. Usually that pointer is the primary key for the supplier record. That makes data entry much easier - you can do something like pick the supplier name out of a combo box and then type in the detail data.

    Another trick that may be useful is the data entry short-cut key CTRL/' - that copies that data from the previous record into the current field. Hope all this helps - Charlotte will probably have some additional insights when the sun reaches her timezone.
    Wendell

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Default Value Previous Field? (Access 2000)

    Hi Tim,
    Are you getting any errors at all? I can't see anything wrong with that code (I'm assuming you put it in a Sub procedure rather than just typing it into the AfterUpdate property box, in which case you'll probably get a macro error message)
    Regards,
    Rory

    Microsoft MVP - Excel

  6. #6
    New Lounger
    Join Date
    Feb 2001
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Default Value Previous Field? (Access 2000)

    Hi again!

    Maybe I need to be clearer. I have a combo box on a form, where the user (me, the poor typist) enters the supplier name for a received piece of inventory. It

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Default Value Previous Field? (Access 2000)

    This is a bound combobox, right? If it isn't bound then the default property doesn't do anything. Since you mentioned a textbox originally, I hadn't realized you were dealing with a combobox. You can do it with code something like this, using the AfterUpdate event of the combo to populate its Tag property and then using that value in the form's Current event to set the combobox's value if it's a new record:

    <pre>Private Sub cboCustomerID_AfterUpdate()
    Me.cboCustomerID.Tag = Me.cboCustomerID.ListIndex
    End Sub 'cboCustomerID_AfterUpdate()

    Private Sub Form_Current()
    Dim cbo As ComboBox

    Set cbo = Me.cboCustomerID
    If Me.NewRecord Then
    If IsNumeric(cbo.Tag) Then
    cbo = cbo.ItemData(CLng(cbo.Tag))
    End If 'IsNumeric(cbo.Tag)
    End If 'Me.NewRecord
    Set cbo = Nothing
    End Sub 'Form_Current()</pre>

    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •