can you help my with the code for my cmdDone to add a new record into my database, i can't seem to get it here is my project http://dl.dropbox.com/u/9153815/Unknown.rar
no luck even with tutorials

Heres a sample on how to add a record to database.

Dim rstInfo As New ADODB.Recordset
Dim SQL as String
SQL = "SELECT * FROM List"
rstInfo.Open SQL, cn, adOpenStatic, adLockOptimistic
rstInfo.AddNew
rstInfo!CustomerName = txtName.Text
rstInfo!ContactNumber = txtContact.Text
rstInfo!Date = txtDate.Text
rstInfo!TimeStart = txtStart.Text
rstInfo!TimeEnd = txtEnd.Text
rstInfo!Event = txtEvent.Text
rstInfo!PossibleNumberofGuest = txtGuest.Text
rstInfo!Comment = txtComment.Text
rstInfo.Update
rstInfo.Close
Set rstInfo = Nothing

Happy coding :D

where show i post that? it's not working for me

Put it in your command button which save the data that is input in your controls.

Usually the saving button ( e.g cmdSave).

Show us some code or where the error occurs.

rstInfo.Open SQL, cn, adOpenStatic, adLockOptimistic

Replace your module code with this.

Public CN As New ADODB.connection
Public rs As New ADODB.Recordset

Public Sub CON()
With CN
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .ConnectionString = "Data Source=" & App.Path & "\Database1.mdb"
     ' so that you dont have to specify the whole drive path of your database
     ' database should be in the same folder as your app
    .Open
    .CursorLocation = adUseClient
End With
End Sub

Replace your Save button code with this.

Dim rstInfo As New ADODB.Recordset
Dim SQL As String

Call CON

SQL = "SELECT * FROM List"

    rstInfo.Open SQL, CN, adOpenStatic, adLockOptimistic
        
        rstInfo.AddNew


            rstInfo!CustomerName = txtName.Text
            rstInfo!ContactNumber = txtContact.Text
            rstInfo!Date = txtDate.Text
            rstInfo!TimeStart = txtStart.Text
            rstInfo!TimeEnd = txtEnd.Text
            rstInfo!Event = txtEvent.Text
            rstInfo!PossibleNumberofGuest = txtGuest.Text
            rstInfo!Comment = txtComment.Text
            
            
    rstInfo.Update
    
         MsgBox "Record has been Saved", vbInformation
    
    rstInfo.Close

CN.Close
    
Set rstInfo = Nothing

when clicked it does not quickly added into my database i need to close my project then open it again

On your save button code, put this between line 26 and 28.

frmList.Adodc.Refresh
frmList.DataGrid1.Refresh

how about if i click the column header then it will be in order

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.