+ Reply to Thread
Results 1 to 2 of 2

Adding a record based on combo

  1. #1
    Registered User
    Join Date
    02-26-2009
    Location
    India
    MS-Off Ver
    Access
    Posts
    46

    Adding a record based on combo

    Hi Friends,

    I am trying to add a record to a child database depending on what the user sees in the combo.

    Once the user determined a record should be added the AddTaskBttn is pressed.

    While the following function adds the serial number to the database when the form is filled out an error message tells me that the record can't be saved because the serial number is null. I have tried to use the doevents but i did't got the appropriate result . Please anyone help.

    see the code i use

    Private Sub AddTaskBttn_Click()
    Dim intX As Integer
    Dim Sn As String
    Sn = Me.CmbTaskList.Column(0)
    DoCmd.SetWarnings False
    DoCmd.RunSQL "Insert Into Tasklist( SerialNumber ) Select '" & Sn & "' As Expr;"
    DoCmd.SetWarnings True
    DoCmd.OpenForm "Task", , , "[TaskList.SerialNumber] =" & "'" & Me.cmbSerialNumber.Column(0) & "'", acFormAdd, acDialog
    For intX = 1 To 200
    Forms!Task!MailingDate_Label.Caption = "Doing something " & intX & " "
    DoEvents
    Next intX
    DoCmd.Close acForm, "Task"
    End Sub

  2. #2
    shanew
    Guest

    Re: Adding a record based on combo

    Just try this

    I have changed the code slightly. When the add task button is pressed the form is supposed to collect the rest of the information for the record. The form now opens and the serial number is added to the database however the rest of the field content on the form does not save.

    Private Sub AddTaskBttn_Click()
    Dim Sn As String
    Sn = Me.cmbSerialNumber.Column(0)
    DoCmd.SetWarnings False
    DoCmd.RunSQL "Insert Into Tasklist( SerialNumber ) Select '" & Sn & "' As Expr;"
    DoCmd.SetWarnings True
    DoCmd.OpenForm "Task", , , "Dockets.SerialNumber =" & "'" & Me.cmbSerialNumber.Column(0) & "'",

    acFormAdd

    End Sub

    On the Form Open of Task I have the following code

    Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
    Sn.Value = Me.OpenArgs
    Me.Requery
    End If
    End Sub

    On the task form I have the following save and close button

    Private Sub FormClose_Click()
    On Error GoTo Err_FormClose_Click
    DoCmd.Save
    DoCmd.Close
    Exit_FormClose_Click:
    Exit Sub
    Err_FormClose_Click:
    MsgBox Err.Description
    Resume Exit_FormClose_Click

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1