Results 1 to 38 of 38

Thread: Help, Unable to add Records into Database

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2008
    Posts
    17

    Re: Help, Unable to add Records into Database

    Sorry my bad!! I posted the wrong Module. Its suppose to be LoadDatabase_Cust


    Anyway ive been tinkering for awhile and now i got *Type MisMatch* from

    Code:
    Dim rsDataCust As DAO.Recordset
     Dim DBConnectionCust As ADODB.Connection
    --------------------------
      
    Private Sub CmdMain_Click()
    Unload Me
    FrmMain.Show
    End Sub
    --------------------
    
    
    Private Sub CmdNext_Click()
            WriteRecord
            rsDataCust.Update
            MsgBox "Patient successfully added !", vbOKOnly
            txtCustId.Text = " "
        TxtCustName.Text = " "
        TxtCustPhone.Text = " "
        TxtCustAdd.Text = " "
        TxtCustLID.Text = " "
        TxtCustIC.Text = " "
        TxtCustAge.Text = " "
         
    End Sub
    -------------------
    Private Sub Form_Load()
    
     
    Set DBConnectionCust = LoadDatabase_Cust(App.Path & "\LoginTest.mdb")
         
    
    Problem Code:
    1. Set rsDataCust = DBConnectionCust.Execute("SELECT * FROM CUSTOMER")
    ^ ^ ^ ^ This line here is the mismatch End Sub ------------------------- Public Sub WriteRecord() With rsDataCust .Edit !cust_id = txtCustId !cust_name = TxtCustName !cust_phone = TxtCustPhone !cust_add = TxtCustAdd !cust_license = TxtCustLID !cust_ic = TxtCustIC !cust_age = TxtCustAge End With End Sub
    The LoadDatabase_Cust Module
    Code:
    Public DBConnectionCust As ADODB.Connection
    
    Public Function LoadDatabase_Cust(ByVal DatabaseName As String, Optional ByVal cust_id As Integer, Optional ByVal cust_name As String, Optional ByVal cust_add As String, Optional ByVal cust_phone As String, Optional ByVal cust_ic As String, Optional ByVal cust_license As String, Optional ByVal cust_age As String) As ADODB.Connection
    
    Dim ConnectionData_Cust As ADODB.Connection
    Set ConnectionData_Cust = New ADODB.Connection
    
    ConnectionData_Cust.Provider = "Microsoft.Jet.OLEDB.4.0"
    ConnectionData_Cust.ConnectionString = "Data Source = " & DatabaseName
    ConnectionData_Cust.CursorLocation = adUseClient
    ConnectionData_Cust.Open = ("Select * FROM CUSTOMER")
    
    Set LoadDatabase_Cust = ConnectionData_Cust
    
    End Function
    For a better view ive included the forms etc in this rar.
    Username : Admin
    (Case sensitive) Password : Test
    Login Test.rar
    Last edited by CountPuchi; May 1st, 2008 at 02:33 PM. Reason: Added the Forms and etc

Posting Permissions

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



Click Here to Expand Forum to Full Width