Doc1.docx

pressing save button i want to store/save all input data in one storage.

attached file is the sample form i made

thanks

Dani AI

Generated

A compact, practical answer for that fills the gap left by earlier replies from and : create a matching table in Access, set an ADO reference in VB6, and use a parameterized ADO command to insert form values. This keeps data typing correct and avoids manual quote-escaping. Use Jet for .mdb files or ACE for .accdb files and always use the full file path and appropriate provider.

Preparation: create an Access table (example name FormData) with fields that match the form controls (e.g., FirstName Text, LastName Text, Age Number). In VB6 set Project -> References -> Microsoft ActiveX Data Objects 2.x Library. Confirm the connection string uses Provider=Microsoft.Jet.OLEDB.4.0 for .mdb or Provider=Microsoft.ACE.OLEDB.12.0 for .accdb.

' Requires reference: Microsoft ActiveX Data Objects 2.8 Library

Private Sub cmdSave_Click()
    Dim cn As ADODB.Connection
    Dim cmd As ADODB.Command

    Set cn = New ADODB.Connection
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Path\MyDB.mdb;"
    ' For .accdb use: "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Path\MyDB.accdb;"

    Set cmd = New ADODB.Command
    Set cmd.ActiveConnection = cn
    cmd.CommandText = "INSERT INTO FormData (FirstName, LastName, Age) VALUES (?, ?, ?)"
    cmd.CommandType = adCmdText

    cmd.Parameters.Append cmd.CreateParameter("p1", adVarWChar, adParamInput, 50, txtFirstName.Text)
    cmd.Parameters.Append cmd.CreateParameter("p2", adVarWChar, adParamInput, 50, txtLastName.Text)
    cmd.Parameters.Append cmd.CreateParameter("p3", adInteger, adParamInput, 0, CInt(Val(txtAge.Text)))

    cmd.Execute

    cn.Close
    Set cmd = Nothing
    Set cn = Nothing
End Sub

Private Sub cmdLoad_Click()
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset

    Set cn = New ADODB.Connection
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Path\MyDB.mdb;"
    Set rs = New ADODB.Recordset
    rs.Open "SELECT FirstName, LastName, Age FROM FormData ORDER BY ID DESC", cn, adOpenForwardOnly, adLockReadOnly

    lstResults.Clear
    Do While Not rs.EOF
        lstResults.AddItem rs!FirstName & " " & rs!LastName & " (" & rs!Age & ")"
        rs.MoveNext
    Loop

    rs.Close
    cn.Close
End Sub

Troubleshooting notes: if "provider not found" appears, install the Microsoft Access Database Engine (ACE) that matches the app bitness (VB6 apps are 32-bit). If numeric or date inserts fail, convert values (CInt, CDate) before passing parameters. For multi-user or bulk scenarios, use transactions and proper indexes. To inspect saved rows directly, open the .mdb/.accdb in Access and view the FormData table.

Recommended Answers

All 4 Replies

do you have any code that you are working on ?

none

here we do not supply code.

You need to show some effort to get any help.

There are lot of sample code in internet. try to search it by any search engine.............

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.