Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003

    Unanswered: adding new record

    Hi, I am trying to add a new record in the form at Acess 97
    Somehow I got error says" type mismatch". Here is my code, please help me! Thx!!!!!!!!!!!!!

    Option Compare Database
    Option Explicit

    Sub AddNewAcct()

    Dim dbsProblemLoanAcct As Database
    Dim rstUserInputDatabase As Recordset
    Dim intAcct As Integer

    Set dbsProblemLoanAcct = CurrentDb

    Set intAcct = dbsProblemLoanAcct.OpenRecordset("UserInput Database", dbOpenDynaset)

    ' Get data from the user.
    intAcct = Trim(InputBox( _
    "Enter the Problem Loan Account number:"))

    ' Proceed only if the user actually entered something
    If intAcct <> "" Then

    ' Call the function that adds the record.
    DoCmd.AddNew rstUserInputDatabase, intAcct

    ' Show the newly added data.
    With rstUserInputDatabase
    Debug.Print "New record: " & ![Acct Num]
    ' Delete new record because this is a demonstration.
    End With

    Debug.Print _
    "You must input an Account Number!"

    End If


    End Sub

    Private Sub AddNew_Click()
    On Error GoTo Err_AddNew_Click

    Call AddNewAcct
    DoCmd.GoToRecord , , acNewRec

    Exit Sub

    MsgBox Err.Description
    Resume Exit_AddNew_Click

    End Sub
    Last edited by applebeez; 11-20-03 at 10:14.

  2. #2
    Join Date
    Nov 2003
    If you comment out: Set intAcct = dbsProblemLoanAcct.OpenRecordset("UserInput Database", dbOpenDynaset)

    will give you "overflow" or "type mismatch" error.

    Please help me. Thank you!

Posting Permissions

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