Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92

    Question Multiple Items Form - Interaction btw Fields

    Hi,

    My database have 2 tables, Clients and Payments.
    I fill Clients form and open Payments form, which is related by a foreign ID.

    The payments form is Multiple Items type, so I can see several records of that table in one form.

    The form has one field called Date of Payment. I can only see the payments related to that client, since the form opens with a filter (the foreign ID).

    I want to do the following: I type a date and when I press TAB to type the next date (which will be a new record, but in the same form) it will be automatically filled with the date I just typed + 1 month.



    So, it's like: get the last record that are showing in the form and add 1 month.
    Or, to be more simple, can be: get the last record of the table and add 1 month.

    How can I do this?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You should be able to use this technique, but use DateAdd() to add a month:

    http://www.mvps.org/access/forms/frm0012.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92

    Question

    Quote Originally Posted by pbaldy View Post
    You should be able to use this technique, but use DateAdd() to add a month:

    http://www.mvps.org/access/forms/frm0012.htm
    Hi pbaldy,

    Thanks for the reply.

    I guess you got this link from here: http://allenbrowne.com/ser-24.html

    And for me, I think the best would be the option B. So I implemented this option and I got this error:

    Object doesn't support this property or method.

    Is it because it's a date? I also have an Input Mask, for dates (00/00/0000;0;_). P.S.: tried without the input mask, same problem.

    Instead of just pressing tab, could also be ok a button, which command will be to copy the last record and paste into a new one.
    Sorry but I have no idea how to start this things.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I got it from where I linked it from. I tested that method and it worked fine with a date. If you're using Allen's method, what line throws the error? I tested with the after update event of the textbox.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    Quote Originally Posted by pbaldy View Post
    I got it from where I linked it from. I tested that method and it worked fine with a date. If you're using Allen's method, what line throws the error? I tested with the after update event of the textbox.
    No specific line. There is no debug option. Just a box with the error and an OK button.

    How do you use Ashish method? I don't know how to implement that.

    I might be going somewhere with this:

    Private Sub DateofPayment_AfterUpdate()
    DateofPayment.DefaultValue = DateAdd("m", 1, Me.[DateofPayment])
    End Sub

    The problem is that is not adding 1 month. I put 01/01/2011 and the next record is 12/30/1899. Doesn't make any sense.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This is in Allen's CarryOver function? Temporarily comment out the line:

    On Error GoTo Err_Handler

    and run the code. You should then be offered the option to Debug, which will take you to the offending line.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This worked for me with Dev's code:

    Const cQuote = """"
    Me!datex.DefaultValue = cQuote & DateAdd("m", 1, Me!datex.Value) & cQuote

    Datex being the name of the control in my test.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    Quote Originally Posted by pbaldy View Post
    This worked for me with Dev's code:

    Const cQuote = """"
    Me!datex.DefaultValue = cQuote & DateAdd("m", 1, Me!datex.Value) & cQuote

    Datex being the name of the control in my test.
    It's not clear to me how to implement this. DefaultValue control? That only allow expression not Event procedure. Whet do I put this expression?

  9. #9
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    Ok I got it.

    Thank you! Working like a charm!

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it working.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    dunnmel4 is offline Novice
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Location
    Wisconsin
    Posts
    14
    Would I be able to see your database? I am trying to create something similar for my current company and I'm a beginner at Access. It would be much appreciated!

  12. #12
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    Quote Originally Posted by dunnmel4 View Post
    Would I be able to see your database? I am trying to create something similar for my current company and I'm a beginner at Access. It would be much appreciated!
    Yes of course.
    All I learned of Access was in forums, with people that help without asking anything back. I'm more than obliged to share my knowledge.

    I will ask you to come here: https://www.accessforums.net/queries...html#post52658

    where I posted my database. It's attached to the post.

    Hope will be useful, but I already advise you that it is in another language. Fortunately the commands and codes are all universal language.

  13. #13
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    Quote Originally Posted by pbaldy View Post
    This worked for me with Dev's code:

    Const cQuote = """"
    Me!datex.DefaultValue = cQuote & DateAdd("m", 1, Me!datex.Value) & cQuote

    Datex being the name of the control in my test.
    One more question related to this. How do I make the same button add +1 to another field?
    The field is a number (integer). I put 1, then when I click to the button that add 1 month to the new record of date field, should add 1 to the new record of this integer field.

  14. #14
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    Ok, here is what I did:

    Me!NumerodaParcela.DefaultValue = "'" & Me!NumerodaParcela.Value & "'"
    Now where the +1 goes?

  15. #15
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    After several tries, here it goes.

    Me!NumerodaParcela.DefaultValue = "'" & Me!NumerodaParcela.Value + 1 & "'"

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Form / Switchbox interaction
    By oleBucky in forum Forms
    Replies: 6
    Last Post: 03-22-2011, 10:58 AM
  2. Counting multiple items in a query
    By slaterino in forum Access
    Replies: 2
    Last Post: 10-14-2010, 08:21 AM
  3. Selecting multiple items from Dropdown
    By Kipster1203 in forum Forms
    Replies: 12
    Last Post: 06-07-2010, 09:20 AM
  4. Multiple detail items per line
    By needafix in forum Reports
    Replies: 3
    Last Post: 10-22-2009, 11:04 AM
  5. Replies: 1
    Last Post: 11-11-2006, 08:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums