By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,953 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,953 IT Pros & Developers. It's quick & easy.

Making new records with VB

P: 19
Hi there,

currently I am trying to get some basic experience with VB6
I was able to make a connection with MS Access already, so I made a form and made use of a ADO DC. Now I can see trough all of the records from that Table in the Database. Now am I trying to make it possible, to create new records using the Form in VB. So I made a Command button, tried some stuff and got stuck.. I have absolutely no clue on how to make a new form, that's why I am posting this here.

Thanks
~F3dde
Apr 10 '07 #1
Share this Question
Share on Google+
6 Replies


P: 47
Hi there,

currently I am trying to get some basic experience with VB6
I was able to make a connection with MS Access already, so I made a form and made use of a ADO DC. Now I can see trough all of the records from that Table in the Database. Now am I trying to make it possible, to create new records using the Form in VB. So I made a Command button, tried some stuff and got stuck.. I have absolutely no clue on how to make a new form, that's why I am posting this here.

Thanks
~F3dde
would u Plz Describe in details.if possible show me the code also
Apr 10 '07 #2

Dököll
Expert 100+
P: 2,364
Hi there,

currently I am trying to get some basic experience with VB6
I was able to make a connection with MS Access already, so I made a form and made use of a ADO DC. Now I can see trough all of the records from that Table in the Database. Now am I trying to make it possible, to create new records using the Form in VB. So I made a Command button, tried some stuff and got stuck.. I have absolutely no clue on how to make a new form, that's why I am posting this here.

Thanks
~F3dde
Hey there, f3dde!

As mentioned, it's a bit unclear as to what you hope to achieve, but I seem to have picked up some hints. Sounds like you can see your database through ADODC but cannot add to your databse. If this is the case, I suggest you keep searching this forum. You may stumble upon notes on the very issue of adding/reading your data to/from database. Please let us know where you are, have a code added in this forum to have a look.

I wish you luck with the project.

In a bit!

Dököll
Apr 12 '07 #3

P: 19
Hey there, f3dde!

As mentioned, it's a bit unclear as to what you hope to achieve, but I seem to have picked up some hints. Sounds like you can see your database through ADODC but cannot add to your databse. If this is the case, I suggest you keep searching this forum. You may stumble upon notes on the very issue of adding/reading your data to/from database. Please let us know where you are, have a code added in this forum to have a look.

I wish you luck with the project.

In a bit!

Dököll

I am able to see my database trough the ADODC. It looks just like the form in Access now. I just want to be able to edit it in the VB form now, which I am not able to do yet. In other words. I'm trying to find out how to code the Command-buttons in order to make a new record. I hope this makes it more clear to you.
Apr 13 '07 #4

Dököll
Expert 100+
P: 2,364
I am able to see my database trough the ADODC. It looks just like the form in Access now. I just want to be able to edit it in the VB form now, which I am not able to do yet. In other words. I'm trying to find out how to code the Command-buttons in order to make a new record. I hope this makes it more clear to you.
You then will need to query your database, like an update statement. You're comfortable typing up a query!

The code you have to read your database can be modified to update...Post what you ahve working, we'll piece it together. How's that for a deal?
Apr 13 '07 #5

P: 19
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
  4. Adodc1.Caption = Adodc1.Recordset.AbsolutePosition & " van " & Adodc1.Recordset.RecordCount
  5. End Sub
  6.  
  7. Private Sub Form_Load()
  8.  Adodc1.Caption = Adodc1.Recordset.AbsolutePosition & " van " & Adodc1.Recordset.RecordCount
  9. End Sub
That is what I currently have, and I suppose this is what you meant. Hope you can help me
Apr 16 '07 #6

P: 19
Alright. Since I've had a critical error which made me delete the whole thing I had to start over again, and because I can't find a way to edit my post I made this new reply.

I had to edit my code, because I was unable to get it to work again using the code I posted earlier.

Currently my code looks like the following:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
  4. Adodc1.Caption = Adodc1.Recordset.AbsolutePosition & " van " & Adodc1.Recordset.RecordCount
  5. End Sub
  6.  
  7.  
  8. Private Sub Form_Load()
  9. Dim strVerbinding As String
  10.   strVerbinding = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\bibliotheek uitleensysteem.mdb"
  11.   With Adodc1
  12.    .ConnectionString = strVerbinding
  13.    .RecordSource = "SELECT * FROM Boek"
  14.    .Refresh
  15.   End With
  16.  
  17.   With txtID_Boek
  18.     Set .DataSource = Adodc1
  19.     .DataField = "ID_Boek"
  20.   End With
  21.   With txtISBN
  22.     Set .DataSource = Adodc1
  23.     .DataField = "ISBN"
  24.   End With
  25.   With txtAuteur
  26.     Set .DataSource = Adodc1
  27.     .DataField = "Auteur"
  28.   End With
  29.   With txtTitel
  30.     Set .DataSource = Adodc1
  31.     .DataField = "Titel"
  32.   End With
  33.   With txtRubriek
  34.     Set .DataSource = Adodc1
  35.     .DataField = "Rubriek"
  36.   End With
  37.   With txtUitleenbaar_in
  38.     Set .DataSource = Adodc1
  39.     .DataField = "Uitleenbaar in"
  40.   End With
  41.   End Sub
  42.  
This is pretty much the same thing exept for the ADO DC, which doesn't show me what I wanted.

Expand|Select|Wrap|Line Numbers
  1. Adodc1.Caption = Adodc1.Recordset.AbsolutePosition & " van " & Adodc1.Recordset.RecordCount
That is what I am using to show me where I am at the navigation. It should show me: "Current book" from "Total amount of books", but for some reason it doesn't refresh and so is behind all the time.

I'm also still trying to find a way to make new records true this form. By looking at some other help sites I've started to think I need to create a "Recordset", which also is a mystery for me.

I hope this update was clear for you, so you can help me.

~F3dde
Apr 16 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.