Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2004
    Location
    Barbados
    Posts
    50

    Unanswered: Option Group problem.

    I have a form which has a buttom to open a subform and here is my problem.

    On the main form, i have an option group called TypeOfVisitor. This option group contains two options - Internal (1) and External (2). When the user clicks on the option Internal, it indicates that the visitor is allowed to borrow books form the library for 14 days. For external, the visitors are only allowed 7 days.

    I have no code in the option group. I do have some code in the DateBorrowed field of the subform. When the date in the DateBorrowed field is entered, the DateDue field should autmatically update according to the TypeOfUser from the option group in the main form. The code I have in the DateBorrowed field is as follows:

    Private Sub DateBorrowed_BeforeUpdate()

    If Forms!frmUsers!TypeOfUser = 1 Then
    Forms!subfrmUserLoans!DateDue = DateBorrowed + 14
    End If
    If Forms!frmUsers!TypeOfUser = 2 Then
    Forms!subfrmUserLoans!DateDue = DateBorrowed + 7
    End If
    End Sub

    I also had it in the AfterUpdate and moved it to the BeforeUpdate event of the Date Borrowed field.

    Any ideas... cause this is not working
    "The extreme always make an impression." - Jeff Hardy

  2. #2
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    Try:

    me.subfrmUserLoans.requery

    Just before the End sub !

    Might be that the subform isn't updating.

    ~Ken

  3. #3
    Join Date
    Feb 2004
    Location
    Barbados
    Posts
    50
    Where do I put that? I've got floats of codes knocking all over both forms.
    "The extreme always make an impression." - Jeff Hardy

  4. #4
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    After_update on the frame should do it. (I hope )

    Let me know if it doesnt.

    ~Ken

  5. #5
    Join Date
    Feb 2004
    Location
    Barbados
    Posts
    50
    There's a compile error - Method or data member not found.
    "The extreme always make an impression." - Jeff Hardy

  6. #6
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    The option group is on the main form?

    The user, selects and option and the subform should appear then update ?

    I take it Dateborrowed is the option group on the main form ?

    Private Sub DateBorrowed_AfterUpdate()
    If Forms!frmUsers!TypeOfUser = 1 Then
    Forms!subfrmUserLoans!DateDue = DateBorrowed + 14
    End If
    If Forms!frmUsers!TypeOfUser = 2 Then
    Forms!subfrmUserLoans!DateDue = DateBorrowed + 7
    End If
    Forms!subfrmUserLoans!DateDue.requery
    End Sub

    Try that..

    Ken.

    PS I'm off home in a moment. So I might have to reply tomorrow if it doesnt work (sorry)

  7. #7
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Smile Re: Option Group problem.

    Originally posted by bajan_elf
    I have a form which has a buttom to open a subform and here is my problem.

    On the main form, i have an option group called TypeOfVisitor. This option group contains two options - Internal (1) and External (2). When the user clicks on the option Internal, it indicates that the visitor is allowed to borrow books form the library for 14 days. For external, the visitors are only allowed 7 days.

    I have no code in the option group. I do have some code in the DateBorrowed field of the subform. When the date in the DateBorrowed field is entered, the DateDue field should autmatically update according to the TypeOfUser from the option group in the main form. The code I have in the DateBorrowed field is as follows:

    Private Sub DateBorrowed_BeforeUpdate()

    If Forms!frmUsers!TypeOfUser = 1 Then
    Forms!subfrmUserLoans!DateDue = DateBorrowed + 14
    End If
    If Forms!frmUsers!TypeOfUser = 2 Then
    Forms!subfrmUserLoans!DateDue = DateBorrowed + 7
    End If
    End Sub

    I also had it in the AfterUpdate and moved it to the BeforeUpdate event of the Date Borrowed field.

    Any ideas... cause this is not working
    Try something along the lines of

    If Me.Parent.TypeOfUser = 1 Then
    Me.DateDue = Me.DateBorrowed + 14
    Else
    Me.DateDue = Me.DateBorrowed + 7
    End If

    Using the Parent property of the Subform and Me to refer to the current form is a lot easier to work with.

    I would try this in the AfterUpdate event of the control.
    Gregg


    DAO, ADO, SQL, Automation and anything else I can pick up.

  8. #8
    Join Date
    Feb 2004
    Location
    Barbados
    Posts
    50
    Ya it's working now... much thanks

    Lisa
    "The extreme always make an impression." - Jeff Hardy

Posting Permissions

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