Results 1 to 4 of 4
  1. #1
    Valkrider's Avatar
    Valkrider is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2012
    Location
    Spain
    Posts
    2

    How to create a new record in one table and the post that value into a form?

    It is a long time since I played around with Access and just getting back into it after a layoff of about 10 years so please forgive the question.

    I have a main table that has a field in it called Family as a long integer. I have a second table called family_group with just one field in it an autonumber.

    I have a form that has the main table fields in it and a combo box to select the family group. This works fine BUT I want to put a button on the form that creates a new record in the family_group table and then displays that value in the combo box. I am certain that I did this type of thing in the past but can't remember how.



    Any tips most welcome.

  2. #2
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    I have a second table called family_group with just one field in it an autonumber.


    This Table will do nothing. You can't even add a Record.

    Perhaps you haven't described it correctly. Please Post your structure and we can take it from there.

    e.g.

    tblOne

    OneField PK Autonumber
    SecondField FK as Long
    ThirdField Text
    etc

    tblTwo
    TwoField PK Autonumber

    etc

  3. #3
    Valkrider's Avatar
    Valkrider is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2012
    Location
    Spain
    Posts
    2
    You are right of course I wasn't thinking things through properly.

    Thinking more logically now what I really want is a button that pops a form allows me to enter a data item, the autonumber will be generated. On closing the popup form the combo box would have the new number added to it.

    Does that give you enough or do you actually need the table details?

  4. #4
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    What I think you want is the code for the Event "Not on List"

    The following I copied from one of my Databases. You will need to adjust to suit your situation. ie Change names ect.

    Private Sub WorkOrderNumber_NotInList(NewData As String, Response As Integer)
    Dim intNewCategory As Integer, intTruncateName As Integer, strTitle As String, intMsgDialog As Integer
    ' Display message box asking if user wants to add a new category.
    strTitle = "This is a New Work Order. Must Create,"
    intMsgDialog = vbYesNo + vbQuestion + vbDefaultButton1
    intNewCategory = MsgBox("You Must add this New Work Order. Continue?", intMsgDialog, strTitle)
    If intNewCategory = vbYes Then
    ' Remove new SubSection from SubSection combo box so
    ' control can be requeried when user returns to form.
    DoCmd.RunCommand acCmdUndo

    ' This is the name of the pop up form which you need to design. FrmWorkOrderDetails

    DoCmd.OpenForm "FrmWorkOrderDetails", acNormal, , , acAdd, acDialog, NewData
    ' Continue without displaying default error message.
    Response = acDataErrAdded
    End If
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 10-28-2011, 02:42 PM
  2. Create one record for every field in another table
    By sailngsue in forum Programming
    Replies: 6
    Last Post: 09-27-2011, 03:57 PM
  3. Create a form that edits a specific record
    By winteram in forum Forms
    Replies: 10
    Last Post: 07-28-2011, 11:46 AM
  4. Replies: 1
    Last Post: 09-21-2010, 09:49 AM
  5. Create PDF for each record in table/form
    By ChrisCMU in forum Forms
    Replies: 15
    Last Post: 07-28-2009, 01:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums