Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2007
    Posts
    30

    Unanswered: Adding a NEW Record Using a Form

    Hi all!

    I have a little dilemma here.
    I have a form called frm_Search that the user can use a Combo Box to select the Company they are looking to get information about.

    If the company does not exist I created another form called frm_AddCompany.
    That form has a Record source of tbl_Company.
    I need to make a button with an event procedure that will add a NEW Record to the tbl_Company and then bring me back to frm_Search so that User can now select the newly created Company.

    My problem is, my current code will not ADD a new record but will only edit the first record in the table.


    Any help is much appreciated!

    Joe

  2. #2
    Join Date
    Nov 2007
    Posts
    30
    Option Compare Database
    Option Explicit

    Private Sub Form_Close()
    Dim cboDTC As ComboBox
    Dim cboBnBName As ComboBox
    ' Return Control object pointing to list box.
    Set cboDTC = Forms!frmBnBSearch!cboDTC
    Set cboBnBName = Forms!frmBnBSearch!cboBnBName
    ' Requery source of data for list box.
    cboDTC.Requery
    cboBnBName.Requery

    End Sub


    ---------------------------------------


    Private Sub cmdCloseForm_Click()
    On Error GoTo Err_cmdCloseForm_Click


    DoCmd.Close

    Exit_cmdCloseForm_Click:
    Exit Sub

    Err_cmdCloseForm_Click:
    MsgBox Err.Description
    Resume Exit_cmdCloseForm_Click

    End Sub

    Here's the actual coding.

  3. #3
    Join Date
    Nov 2007
    Posts
    30
    Nevermind!

    Found out the Command I need.

    I needed it to go to the last record (so when I close the form it adds the correct records)

    I set an Open Event Procedure that simply said:

    DoCmd.GoToRecord , , acNewRec

    That fixed it.

    Joe

Posting Permissions

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