Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Star Lounger
    Join Date
    Mar 2002
    Location
    Chicago, Illinois, USA
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Field default value in a form (2000)

    I have a table with three fields in each record: managed net outstandings, held net outstandings and Data Date. A form named "update outstandings" is used to populate these fields in the underlying table. What I would like to do is have "held net outstandings" default to the value of "managed net outstandings" as the data is entered in the form. I'd also like the "data date" field values to default to the first "data date" entry made, since all the records will be updated at the same time. I've tried playing with the "after update" control in "managed net outstandings" and "data date", but I can't seem to get it to work correctly (compile error, can't find project or library). Any help would be greatly appreciated. Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Field default value in a form (2000)

    When you get the "Can't find project or library" error, what part of your code is highlighted?

  3. #3
    Star Lounger
    Join Date
    Mar 2002
    Location
    Chicago, Illinois, USA
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field default value in a form (2000)

    I'm just learning to code in Access, so I apologize if this is way off...

    Anyway, the first thing I tried to tackle was the default for the "Data date" field.

    Private Sub Last_Update_Date_AfterUpdate() <-- This is highlighted when the compile error box pops up.

    Update_Outstandings!Data_Date.DefaultValue = """" & Update_Outstandings!Data_Date.Value & """"

    End Sub

    I'm not sure where to begin to get the "net outstandings" to default to the "managed outstandings."

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Field default value in a form (2000)

    In the first place, remove Update_Outstandings! (twice). If you needed to refer to the form explicitly (which you don't, since you're on that form), it should have been Forms!Update_Outstandings!..., but you can omit it here.

    See if the error goes away.

    If not, what is Last_Update_Date? The line after it mentions Data_Date, so shouldn't it be Data_Date? See what happens if youchange Last_Update_Date_afterUpdate to Data_Date_AfterUpdate.

    Note for the future: you have used names for fields, controls and form with spaces in them. Although this is allowed, it is not to be recommended. It makes coding more difficult; as you can sse here, Access has replaced spaces by underscores. You can always set the caption property of fields to make labels display user-friendly text.

  5. #5
    Star Lounger
    Join Date
    Mar 2002
    Location
    Chicago, Illinois, USA
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field default value in a form (2000)

    Yes, I realized I shouldn't be using spaces long after I should have...

    Anyway, I changed it to:

    Private Sub Last_Update_Date_AfterUpdate()

    Last_Update_Date.DefaultValue = """" & Last_Update_Date.Value & """"

    End Sub

    It now runs without error, but nothing happens. Shouldn't this populate the remaining Last_Update_Date fields in the table with the same value?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Field default value in a form (2000)

    Open your form in design view.
    Select the "Last Update Date" control.
    Activate the Properties window, Events tab
    Click in the AfterUpdate event.
    If it hasn't been selected, select Event Procedure.
    Click the builder button (the three dots ...)
    You should be taken to your procedure.
    Switch back to Access, and save the form.
    Test if AfterUpdate now works.

  7. #7
    Star Lounger
    Join Date
    Mar 2002
    Location
    Chicago, Illinois, USA
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field default value in a form (2000)

    No Joy [img]/forums/images/smilies/sad.gif[/img]

    Is there a setting somewhere in the table or form that would prevent this from working? Also, I have the date field configured as MM/YYYY.

    BTW, thank you for your patience and help.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Field default value in a form (2000)

    Try the following:

    Repeat the steps from my previous reply until you are in the Visual Basic Editor (or return there if it is still open).
    Click in the margin to the left of the line Private Sub Last_Update_Date_AfterUpdate()
    The line should be highlighted in brown, and should be marked by a brown bullet in the left margin. This is called a breakpoint.
    Switch back to Access, and open the form. Change the date and press Tab or Enter.
    You should be taken to the Visual Basic Editor, with execution of the event procedure paused at the breakpoint.
    If that doesn't happen, something must have gone wrong when you followed the steps from my previous post.
    If it does, single step through the code by pressing F8 repeatedly.
    Does the highlighted yellow line move down, and disappear when you've come to the end of the procedure?

  9. #9
    Star Lounger
    Join Date
    Mar 2002
    Location
    Chicago, Illinois, USA
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field default value in a form (2000)

    Yes, the highlighted yellow line moves down through the steps and disappears at the end.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Field default value in a form (2000)

    I'm afraid I don't understand why it doesn't work. Let's try something different.

    In <!mskb=210236>Microsoft Knowledge Base Article 210236<!/mskb>, Microsoft describes a method of filling one or more fields in a new record with values from the previous record. You can also download a sample database with a form that demonstrates this method. I hope that you can apply it to your database.

    I hesitate to ask it, but if you wish, you can attach a stripped down, sanitized, compacted and zipped version of your database to a post. That way, other Loungers can try to pin down the problem. Remove everything that is not needed to demonstrate the problem. The zip file should be less than 100 KB.

  11. #11
    Star Lounger
    Join Date
    Mar 2002
    Location
    Chicago, Illinois, USA
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field default value in a form (2000)

    I stripped it down to the table and the form. If someone could help me get the net outstanding value to default to the value in managed outstandings and get my date problem fixed, I would be very grateful, as I am already for the help.

    Thanks,

    Brett
    Attached Files Attached Files

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Field default value in a form (2000)

    It works! But what in heavens name is your purpose? The form doesn't allow adding a new record, so you'll never see the effect of setting the default value! <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

    I have set Allow Additions to Yes, and added code to set the default value (and optionally the value in the current record) of Held Net Outstandings to the value of Managed Net Outstandings.
    Attached Files Attached Files

  13. #13
    Star Lounger
    Join Date
    Mar 2002
    Location
    Chicago, Illinois, USA
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field default value in a form (2000)

    Trust me, there is another form for this table that allows for records (vendors and vendor numbers) to be added. [img]/forums/images/smilies/smile.gif[/img] This form is for only updating the outstandings $$. There is also an append query that moves the old outstanding values to a different table when you open this form.

    Anyway, I really appreciate the help. I'll let you know tomorrow if I was able to get it to work.

    Regards,

    Brett

  14. #14
    Star Lounger
    Join Date
    Mar 2002
    Location
    Chicago, Illinois, USA
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field default value in a form (2000)

    Good news and bad news. Good news: The net outstanding field defaults to the managed outstanding without a problem. Bad news: Bad communication on my behalf. What I'm trying to do is when the date is changed in the first record, I want it to change the date field for the rest of the existing records. For example, all of the records have a date of 4/2003. When I update the first record to 5/2003, I want the rest of the records to default to that value as well. Is this even possible?

    Thanks for all of your help.

    Brett

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

    Re: Field default value in a form (2000)

    Defaults only apply to new records. Do you mean you want the rest of the records *updated* to the new date? *All* existing records?
    Charlotte

Page 1 of 2 12 LastLast

Posting Permissions

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