Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2009
    Posts
    13

    Question Unanswered: Desperate Help Needed! Forms/Subforms

    I have a master form and a subform. The master form has a combo box that's unbounded (Unit Number) based on a query - and a series of text boxes that are filled in from an AfterUpdate [Event Procedure] that looks like the code below. This data is just for verification purposes only for the end user. This took me 2 days to figure out how to automate the text boxes from the combo. Bare with me.

    Me.Serial_Number = Me.Combo14.Column(1)
    Me.Type = Me.Combo14.Column(2)
    Me.Model = Me.Combo14.Column(3)
    Me.Department = Me.Combo14.Column(4)
    Me.Model_Year = Me.Combo14.Column(5)
    Me.Comments = Me.Combo14.Column(6)

    Now I want to add a SubForm that will bring up only the data (Date of Record, Meter Reading, Comments) that corresponds to the value in the Combo Box (Unit Number). The user should simply type in a unit number, hit enter, and it should bring him down to the next open slot in the subform. I want the end user to type in the next meter reading in the subform and simply hit enter again repeat the process. Any suggestions?

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Base the subform on a query that looks at the table holding the required data. Set a selection criterion on the query under the unit number field:
    [Forms]![MasterFormName]![Combo14]
    Add to your AfterUpdate event a line to requery the subform.

    HTH!
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  3. #3
    Join Date
    Jul 2009
    Posts
    13
    I keep getting a message "primary key can't contain a null value"..What do I do now?

  4. #4
    Join Date
    Jul 2009
    Posts
    13
    My code looks like this:
    Private Sub Combo14_AfterUpdate()
    Me.Serial_Number = Me.Combo14.Column(1)
    Me.Type = Me.Combo14.Column(2)
    Me.Model = Me.Combo14.Column(3)
    Me.Department = Me.Combo14.Column(4)
    Me.Model_Year = Me.Combo14.Column(5)
    Me.Comments = Me.Combo14.Column(6)

    Me.Subform_Meters.Requery

    End Sub

  5. #5
    Join Date
    Jul 2009
    Posts
    13
    It worked. You guys seriously RULE! haha. I hate Access.

    Is there any way to get my values that are typed in to add the difference? Say in period 1-A piece of equipment has a meter reading of 100.
    In period 2-that same piece of equipment has a reading of 500. That means the usage for that period is 400 hours. I would want to display this in a report.

  6. #6
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    "Primary key can't contain null value" implies that the database is trying to save a record without a value in the key field. Nothing that you've so far posted explains how that happens.

    If you're working in Access 2000, you could always post a zipped copy of your database and I'll have a look at it over the weekend.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

Posting Permissions

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