Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2016
    Posts
    1

    Unanswered: change source main form through selection subform

    Hi,

    I've got a form frmWorkorders with a subform (as datasheet) with all open work orders. (all coming from tblWorkorders)
    The idea is to have an overview of all open work orders (subform based on query (so not all the fields are shown here)) and when a work order in the subform is selected the main form fields adapt and give me al the info of that specific record.

    At the moment I use textbox (txtWerkbonnummer) that is on the main form with source: =[subFormRevisie].[Form]![Werkbon]
    So this textbox has the work order id in it.

    I wanted to use the change event on the textbox but that doesn't work when the textbox value is changed through VBA code.

    So I used the Click event to test if it could work..

    Code:
    Private Sub txtWerkbonnummer_Click()
    Dim strNewRecord As String
    
     strNewRecord = "SELECT * FROM tblWerkbonnen " & " WHERE Werkbon = " & Me!txtWerkbonnummer.Value
     Me.RecordSource = strNewRecord
    
    End Sub
    How should I approach this??

    Thanks!

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    The way i have done this sort of thing in the past is to have the main form hold the many, sekecting a tow in the main form then shows the detail. I dont use datasheets as they are, in my opinion not flexible enough.
    So main form is continuous. Displays the minimum data needed to identify what row you want to examibe in detail in the sub form
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    May 2016
    Posts
    83
    Provided Answers: 3
    Hi Lanssens

    I don't really understand what is the target of
    txtWerkbonnummer? And [subFormRevisie].[Form]![Werkbon is subform in frmWorkorders ?

    Last edited by informer; 06-12-16 at 14:17.

Posting Permissions

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