Results 1 to 15 of 15

Thread: Date Add

  1. #1
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Red face Unanswered: Date Add

    I have Main form and Subform. I have one date field in MainForm when i put the date in main form i want in subfrom date to add 2 weeks from main from date.

    For example: Main form "DelivDate" 03/04/2004.........i want subform field "TragetDate" to be "DelivDate + 2Weeks" so it would be 03/4/2004 + 2 Weeks = 03/18/2004

    Does anyone have any idea how to accomplise this. I have accomplise this when i have to do this on one form but not within subform

    Thanks in advance
    Skharva

  2. #2
    Join Date
    Feb 2004
    Location
    Houston, Texas
    Posts
    45
    Not sure which event you are using for a trigger but this code should accomplish what you want (I think)...

    Me.subFormName.Form.txtBoxName.Value = now() + 14

    ...rtk

  3. #3
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Red face Date ADD

    Originally posted by rtkracht
    Not sure which event you are using for a trigger but this code should accomplish what you want (I think)...

    Me.subFormName.Form.txtBoxName.Value = now() + 14

    ...rtk
    It didn't wrk but i try this and still doesn't wrk any idea why ?

    =DateAdd([d],14,[tblInfants. BirthDate])
    Skharva

  4. #4
    Join Date
    Feb 2004
    Location
    Houston, Texas
    Posts
    45
    This works for me.
    x = DateAdd("d", 14, "3/5/2004")
    debug.print x

    I don't think [tblInfants. BirthDate] is valid. Should be a value from a control on your form (combobox, textbox, etc.).

    ..rtk

  5. #5
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by rtkracht
    This works for me.
    x = DateAdd("d", 14, "3/5/2004")
    debug.print x

    I don't think [tblInfants. BirthDate] is valid. Should be a value from a control on your form (combobox, textbox, etc.).

    ..rtk
    Yes, i understand that but i want the data to be added in subfrom field based on Mainform field. MainForm(frmInfants) date field is "BirthDate"
    and subfrom(subTragetDate) date field is "TragetDate". Now when ever user type in the BirthDate i want TragetDate to be BirthDate + 2 weeks.

    Thanks
    Skharva

  6. #6
    Join Date
    Feb 2004
    Location
    Houston, Texas
    Posts
    45
    So your are saying that:

    Me.subTragetDate.Form.TragetDate.Value = _
    DateAdd("d", 14, me.BirthDate.value)

    (where me.Birthdate is a textbox (or some other control) )

    doesn't work?
    rtk

  7. #7
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by rtkracht
    So your are saying that:

    Me.subTragetDate.Form.TragetDate.Value = _
    DateAdd("d", 14, me.BirthDate.value)

    (where me.Birthdate is a textbox (or some other control) )

    doesn't work?
    rtk

    No it doesn't wrk. Would it help if i send copy of databae ? Its in Access 2000
    Skharva

  8. #8
    Join Date
    Feb 2004
    Location
    Houston, Texas
    Posts
    45
    That would be a good idea but I only have Access 97 here. Can you convert to 97 and then send?
    rtk

  9. #9
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    date add

    Originally posted by rtkracht
    That would be a good idea but I only have Access 97 here. Can you convert to 97 and then send?
    rtk
    its in 97
    Attached Files Attached Files
    Skharva

  10. #10
    Join Date
    Feb 2004
    Location
    Houston, Texas
    Posts
    45
    take a look at the vb code in the main form. that's what I was referring to.
    rtk
    Attached Files Attached Files

  11. #11
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Thumbs up Date ADD

    Originally posted by rtkracht
    take a look at the vb code in the main form. that's what I was referring to.
    rtk
    Thanks that help alot
    Skharva

  12. #12
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Re: Date ADD

    Originally posted by Skharva
    Thanks that help alot
    Attached Files Attached Files
    Skharva

  13. #13
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Re: Date ADD

    Originally posted by Skharva
    Thanks that help alot
    What u send me wrks fine. But when i put that subfrm in diff main form it doesn't wrk. I'm attaching the database again. Open frmMother

    Thanks
    Attached Files Attached Files
    Skharva

  14. #14
    Join Date
    Feb 2004
    Location
    Houston, Texas
    Posts
    45
    Looks like you've been busy. Note my comment in the code.
    good luck... rtk

  15. #15
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by rtkracht
    Looks like you've been busy. Note my comment in the code.
    good luck... rtk
    I'm sorry but i don't see any comment in the code all i have is this

    Private Sub Form_Open(Cancel As Integer)
    Me.SubTragetDate.Form.txtTargetDate.Value = DateAdd("d", 14, Me.txtBirthDate.Value)
    End Sub


    Thanks
    Skharva

Posting Permissions

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