Frm/SubFrom Troubles

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ozjules
    New Member
    • Mar 2008
    • 1

    Frm/SubFrom Troubles

    Hi Guys,

    Need your help with the following as I've been looking at it for far too long and seem to be over complicating it. I'm building an Admin section to a database where a list of Programs can be updated and maintained. So far I have the following:

    tblProgram: ProgramID (primary key, autonumber, indexed no dublicates) and Program Name + additional fields that I want the users to be able to amend.

    qryProgramStruc ture: holds the contents of tblProgram

    frmAdmin: RecordSource = qryProgramStruc ture. Has a listbox who's row source is ProgramID and ProgramName from qryProgramStruc ture and subfrmProgram which holds the additional fields I want to be able to amend.

    All of this works fine and I can amend the records in the subfrm and see the changes if I open tblProgram. Where I've come unstuck is I want the user to be able to add a record to the subfrmProgram using a cmd button on frmAdmin. I've got the following code entered On Click and the subfrm does go to a new record however the autonumber is duplicating numbers rather than selecting the next number.
    [code=vb]
    Private Sub Command93_Click ()

    If Me!subfrmProgra m.Form.Dirty Then
    Me!subfrmProgra m.Form.Dirty = False
    End If

    Me!subfrmProgra m.SetFocus

    DoCmd.GoToRecor d , , acNewRec

    End Sub
    [/code]
    Is this something to do with the fact I've got the qry/table referenced with the listbox and the subform and it's getting confused or something else?

    Any help or advice on how to fix it would be great

    Ozjules
Working...