Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006
    Posts
    40

    Unanswered: Urgent request - AddRecord issue (VBA)

    Hi guys,

    i tried using the AddRecord command (Record operation - Add New Record) provided by MS Acess but the new record is not been appended to the table but instead it has been overwritten. I have set the focus for the field under the acNewRec already. By right i shld be able to append the record at the end of the record of the field and nt overwritting the record. What i want to achieve is to be able to select the value from the combo box corresponding to the table 'Student' and append the record based on what have been selected from the combo box (Predefined list) and the remaining textbox values.

    Implementation logic

    primary key
    SerialCode (Autokey)

    Fields
    StudentId, subjectcode, course, grade

    Combo box
    StudentId (predefined list) - S1, S2, S3, S4, S4, S5

    AddRecord command (by Acess under operation)
    acNewRc
    StudentId.SetFocus
    subjectCode.SetFocus
    course.SetFocus
    grade.SetFocus

    code

    Private Sub AddRecord_Click()
    On Error GoTo AddRecord_Click
    DoCmd.OpenForm "Record"
    DoCmd.GoToRecord, "Record", acNewRec
    Combo1.SetFocus 'predefined list
    StudentId.SetFocus 'bound to controlsource studentId
    course.SetFocus 'bound to controlsource course
    subjectCode.SetFocus
    Grade.SetFocus
    Exit_AddRecord_Click:
    Exit Sub
    Err_AddRecord_Click:
    MsgBox Err.Description
    Resume Exit_AddRecord_Click

    End Sub
    Private Sub Combo1_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[SerialCode] = " & Str(Nz(Me![Combo1], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub


    Tks for your assistance.

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Dude.... How many times are you gonna ask the same question?

    What are your trying to do with this:

    Combo1.SetFocus 'predefined list
    StudentId.SetFocus 'bound to controlsource studentId
    course.SetFocus 'bound to controlsource course
    subjectCode.SetFocus
    Grade.SetFocus


    Do each of the controls have a Got Focus event that is supposed to fire?
    Inspiration Through Fermentation

Posting Permissions

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