Save data to Access MDB in VB6

difficulties to save information in a .mdb file

Page 1 of 1

10 Replies - 26409 Views - Last Post: 08 June 2008 - 07:48 AM Rate Topic: -----

#1 joyz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-May 08

Save data to Access MDB in VB6

Post icon  Posted 05 June 2008 - 09:19 AM

Private Sub Form_Load()
Data1.data source=" & App.Path & "\Pro5.mdb"
Data1.RecordSource = "select * from Customer"
End Sub

Private Sub cmdSave_Click()

name1 = txtName.Text

address1 = txtAddress.Text

number1 = txtNumber

bought1 = txtBought.Text

Data1.Recordset.addnew

Data1.Recordset.Fields("Cust_Name") = name1

Data1.Recordset.Fields("Cust_Address") = address1

Data1.Recordset.Fields("Cust_Number") = number1

Data1.Recordset.Fields("Cust_Bought") = bought1

Auto1 = Data1.Recordset.Fields("code")

Data1.Recordset.Update

End Sub




'the file Pro5.mdb is in the same folder as the forms and other files of VB 6. i want when i click on the command button, the information like name1, address1, number1, bought1 are being saved in the database file Pro5.mdb, but with the actual code that i have written it don't work and i think the problem is found in the Private Sub Form_Load(), as the code for the source is not correct.

thanks, for paying attention to the my problems
Joyz

Is This A Good Question/Topic? 0
  • +

Replies To: Save data to Access MDB in VB6

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Save data to Access MDB in VB6

Posted 05 June 2008 - 09:31 AM

This in the wrong forum, please, when posting programming questions post them in the correct forum where they can get the attention they need. This forum is reserved for C and C++ code, you should post these questions in the Visual Basic forum.

Ill see if I can get this moved for you
Was This Post Helpful? 0
  • +
  • -

#3 joyz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-May 08

Re: Save data to Access MDB in VB6

Posted 05 June 2008 - 10:22 AM

no, it's real the visual basic forum..you may have been mistaken.
Was This Post Helpful? 0
  • +
  • -

#4 mensahero  Icon User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

Re: Save data to Access MDB in VB6

Posted 05 June 2008 - 11:02 AM

Quote

no, it's real the visual basic forum..you may have been mistaken.


thats because it was just moved.



what seems to be the error? is there any? or its just plain not working?

if you may.. could you upload the project so I can probably test it myself.

This post has been edited by mensahero: 05 June 2008 - 11:06 AM

Was This Post Helpful? 0
  • +
  • -

#5 joyz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-May 08

Re: Save data to Access MDB in VB6

Posted 06 June 2008 - 04:56 AM

View Postjoyz, on 5 Jun, 2008 - 10:22 AM, said:

no, it's real the visual basic forum..you may have been mistaken.


it's quite difficult to send the complete project here....because there are more than one form in it.
but it doesn't matter...just send me the code for saving items from a given form to a database.
i cannot upload it no more cause it is about 2MB. but i can still send it to you if i have your email or something like this
thanks
Was This Post Helpful? 0
  • +
  • -

#6 Zhalix  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 260
  • Joined: 07-May 08

Re: Save data to Access MDB in VB6

Posted 06 June 2008 - 05:02 AM

View Postjoyz, on 6 Jun, 2008 - 05:56 AM, said:

it's quite difficult to send the complete project here....because there are more than one form in it.


Compress it.
Was This Post Helpful? 0
  • +
  • -

#7 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 187
  • View blog
  • Posts: 4,673
  • Joined: 26-November 04

Re: Save data to Access MDB in VB6

Posted 07 June 2008 - 12:19 AM

Quote

it's quite difficult to send the complete project here....because there are more than one form in it.

Add all the files in a ZIP or tarball archive and post it here.
Was This Post Helpful? 0
  • +
  • -

#8 mensahero  Icon User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

Re: Save data to Access MDB in VB6

Posted 07 June 2008 - 12:55 AM

View Postjoyz, on 6 Jun, 2008 - 04:56 AM, said:

View Postjoyz, on 5 Jun, 2008 - 10:22 AM, said:

no, it's real the visual basic forum..you may have been mistaken.


it's quite difficult to send the complete project here....because there are more than one form in it.
but it doesn't matter...just send me the code for saving items from a given form to a database.
i cannot upload it no more cause it is about 2MB. but i can still send it to you if i have your email or something like this
thanks


lmao.. like the above post you can compress it..

well if you think you can use whatever code directly into your project.. heres my way of saving stuff..

with db.recordset

.addnew
.fields("someField") = text1.text
.update

end with


thats assuming you are properly connected to the database.. :blink:
Was This Post Helpful? 0
  • +
  • -

#9 joyz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-May 08

Re: Save data to Access MDB in VB6

Posted 08 June 2008 - 02:36 AM

ok...here it is............

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#10 mensahero  Icon User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

Re: Save data to Access MDB in VB6

Posted 08 June 2008 - 03:29 AM

View Postjoyz, on 8 Jun, 2008 - 02:36 AM, said:

ok...here it is............


well first.. you have two form_load on the first form.. and I try to resolved it I've noticed a bunch of errors popping up.. its better if you clean the program first before letting others see it.. I can't even go to the problem you are actually facing.. :blink:

This post has been edited by mensahero: 08 June 2008 - 03:29 AM

Was This Post Helpful? 0
  • +
  • -

#11 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 187
  • View blog
  • Posts: 4,673
  • Joined: 26-November 04

Re: Save data to Access MDB in VB6

Posted 08 June 2008 - 07:48 AM

You have two Form_Load() comments.
Comment these two lines like this:
'Private Sub Form_Load()
'On Error Resume Next

They are located at the beginning of the frmsales_Add form code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1