Results 1 to 5 of 5

Thread: Help (A2k SR1)

  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help (A2k SR1)

    I made a post some time ago but have made a number of changes to the database.

    I have a form (frmCheckInLatest) to extend a guest

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

    Re: Help (A2k SR1)

    If you're already looking at the previous record in your AutoFillNewRecord function, then you should be able to recalculate the Checkout date for that record and set the [RentBegDate] for the new record to the value of that calculation. If you have trouble figuring it out, post the code for the AutoFillNewRecord function and someone will be able to help with the details.
    Charlotte

  3. #3
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help (A2k SR1)

    My AutoFillNewRecord (F As Form) function came from Microsoft knowledge base (Q210236). I have an invisible text box that has the DefaultValue set for the fields that I want to fill in the new record. FrmCheckInLast has the OnCurrent property set for =AutoFillNewRecord([Forms]![frmCheckInLast])

    ModAuto_Fill_New_Record is as follows:

    Option Compare Database

    Option Explicit

    Function AutoFillNewRecord(F As Form)
    Dim RS As DAO.Recordset, C As Control
    Dim FillFields As String, FillAllFields As Integer

    On Error Resume Next

    'Exit if not on the new record.
    If Not F.NewRecord Then Exit Function

    'Goto the last record of the form recordset to autofill form)
    Set RS = F.RecordsetClone
    RS.MoveLast

    'Exit if you cannot move to last record (no records).
    If Err <> 0 Then Exit Function

    'Get the lost of fields to autofill.
    FillFields = ";" & F![AutoFillNewRecordFields] & ";"

    'If there is no criterioa field, then set flag indicating All
    'fields should be autofilled.
    FillAllFields = Err <> 0

    F.Painting = False

    'Visit eadch field on the form.
    For Each C In F

    'Fill the field if ALL fields are to be filled OR if the
    '...ControlSource field can be found in the FillFields list.
    If FillAllFields Or InStr(FillFields, ";" & (C.Name) & ";") > 0 Then
    C = RS(C.ControlSource)
    End If
    Next

    F.Painting = True


    End Function

    ************************************************** **********
    The [CheckOutDate3] date is displayed on the last rental record.

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

    Re: Help (A2k SR1)

    Omit RentBegDate from the string in FillFields, and add the following to your function.

    If F.Name = "frmCheckInLast" Then
    F("RentBeginDate") = RS("CheckOutDate3")
    End If

    If CheckOutDate3 is not calculated in the record source of the form, but in the control source of a control on the form, you must calculate it here too:

    F("RentBeginDate") = DateAdd("y",RS("NumberofDays"),RS("RentBegDate"))

  5. #5
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help (A2k SR1)

    Hans,

    Many thanks! Works like a charm.

    Tom

Posting Permissions

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