Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397

    Unanswered: Radio Button : Run-time error '13'

    Hi,

    I am using few unbound fields named SODate, Agencey name, Deliverydate and 2 radio buttons (named ExportOrder and LocalOrder) on header form.
    I set default value of radion buttons to 0.

    I need to add few days like below to the SODate and re-appear it into Deliverydate field so that deliverydate will be + 60 days or +90 days.

    SOdate is automatically filled up with current date when new record is entered.

    When I update any of the radio button, it should add 60 or 90 days (depend on the either radio button I used).

    Private Sub ExportOrder_AfterUpdate()
    If ExportOrder.Value = True Then
    Me.Recalc
    Me.LocalOrder.Value = False
    Me.DeliveryDate = SODate + 90
    Else
    Me.DeliveryDate = SODate + 60
    End If
    End Sub

    But it gives the subjected error showing "type mismatch".

    How can I add days into date?

    Can you please extend your help?
    With kind regards,
    Ashfaque

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    i'd expressly convert the value of sodate to a date using either CDATE()
    have yoiu checked what vaue is in sodate
    alternatively I'd consider changing it to
    Code:
    If ExportOrder.Value = True Then
    Me.Recalc
    Me.LocalOrder.Value = False
    Me.DeliveryDate = date() + 90
    Else
    Me.DeliveryDate = date() + 60
    End If
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397
    Thanks healdem,

    Yes, I checked the value of SODate which shows"07-08-08" as the recrord is entered today.

    Can you please tell how can use CDate() for SODate field which is unbound?
    With kind regards,
    Ashfaque

  4. #4
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397
    Thanks healem again,

    I followed you and got it..

    If ExportOrder.Value = True Then
    Me.Recalc
    Me.LocalOrder.Value = False
    Me.DeliveryDate = CDate(SODate) + 90
    Else
    Me.DeliveryDate = CDate(SODate) + 60
    End If
    With kind regards,
    Ashfaque

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    a text box has a default data type of string/text. so trying to assign a value of type text + a number is going to be indeterminate

    when you get a type mismatch and the code looks ok, you probably need to explicitly cast/convert the data type. although the Access parser does a very impressive job of making correct conversions between different datatypes sometimes it needs help.

    incidentally it may make more sense to use the dateadd function to make your code more transportable.... your code is taking advantage of the way JET stores dates... dateadd is platform independant.. and should work on any type of data backend.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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