I have a MS Access database. If I want to create a function in VB6 that adding data into my data base by typing the new data on textbox and click the button. Is it possible.
How do i adding new data to my database? Hope to getting help from here. Thanks you very much

This is my code.... any problem? Why cant work?

Private Sub Command1_Click()
Data1.Recordset.Field(1).Value = InputBox("code")
End Sub

Private Sub Command6_Click()

    Do While Not Data1.Recordset.EOF
     Picture2.Print Data1.Recordset![code]
     Text5.Text = Text5.Text & " " & Data1.Recordset![code]

     'Text5.Text = Data1.Recordset![code]
End Sub

Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\menu1.mdb"
    Data1.RecordSource = "Table1"

    Text1.DataField = "Code"
End Sub

Recommended Answers

All 5 Replies

Try this one...
First save your database and project on the same folder. 2nd create/add a module then put this in your module.

Option Explicit
Public db As Database

Sub Main
     Set db=OpenDatabase(App.Path & "\menu1.mdb")
End Sub

3rd Go to Project menu select Project Properties. On the Startup object select the Sub Main

In your Form1 where you add a data in you db put this code

Private Sub Form_Load()
     Set Data1.Recordset=db.Openrecordset("Select * from [[I]name of the table[/I]]")
End Sub

Private Sub AddBtn_Click()
     With Data1.Recordset
    End With
End Sub

Hi nuin,

After adding Data To the Table, u will have To Refresh, then only newly added data will show up.
Check this :

Data1.Recordset.Field(1).Value = InputBox("code")


Thanks you i got it le..
now my database problem all solve...
Thank you everyone...
But Now turn to the Timer part problem...x_x

Pls help me...
how do I print my files on database

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.