Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 26th, 2006, 06:02 PM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Small problem VB (thanks!)

 Can someone help me with this simple code. The code in bold doesn't work (just an update on a table). Any idea?

 Many thanks!

 Kris

Private Sub Command4_Click()
On Error Resume Next
DoCmd.RunCommand acCmdSaveRecord

Dim Result As Integer

Dim Dbs As DAO.Database
Dim rst1, rst2, rst3 As DAO.Recordset
Set Dbs = CurrentDb
Dim Record_ID As Integer
'Main Record
Set rst1 = Dbs.OpenRecordset("SELECT * FROM qry_Import;")
Set rst2 = Dbs.OpenRecordset("SELECT * FROM tbl_Case ORDER BY tbl_Case.Record_ID;")

Result = MsgBox("Transfer?", vbOKCancel, "Confirmation")
Select Case Result
  Case vbOK

  rst1.MoveFirst

  While Not rst1.EOF

  rst2.AddNew
  rst2!Nom = rst1!id_nome
  rst2!Prénom = rst1!id_apelido
  rst2.Update
  rst2.MoveLast
  Record_ID = rst2!Record_ID


  'add autre nom dans la table tbl_Autre_Nom

  Set rst3 = Dbs.OpenRecordset("tbl_Autre_Nom")
  rst3.AddNew
  rst3!Record_ID = Record_ID
  rst3!Autre_Nom = rst1!id_outronome
  rst3.Update
  rst3.Close

  'Update database quandidat pour record transfere

rst1.Edit
  rst1!id_Transfered = True
  rst1!id_To_be_Transfered = False
  rst1.Update
  rst1.MoveNext


  Wend

  rst2.Close
  rst1.Close
Case vbCancel
  Me.Undo
  DoCmd.CancelEvent
End Select

Me.Requery

End Sub


Reply With Quote
  #2 (permalink)  
Old November 27th, 2006, 02:33 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi Kris

By default the cursor will be forwar-only. You can read the records but not update using this cursor.

Use either dynamic or keyset for updation

rst1.CursorType = adOpenDynamic

should do that

Cheers
Shasur

http://www.vbadud.blogspot.com
Reply With Quote
  #3 (permalink)  
Old November 27th, 2006, 12:11 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Shasur
 Hi Kris

By default the cursor will be forwar-only. You can read the records but not update using this cursor.

Use either dynamic or keyset for updation

rst1.CursorType = adOpenDynamic

should do that

Cheers
Shasur

http://www.vbadud.blogspot.com
You might note that this is DAO and not ADO, and things like CursorType are not part of the DAO Recordset object.

I suggest removing the On Error Resume Next, and step through the code to determine where as error might be occuring.

Also, it is probably not possible - but it would be a good idea to upgrade everything to ADO if you can. I assume this us VB6? DAO went out of general use at least 5 years ago, and even then it was used only for legacy applications that didn't have much life left in them.

Woody Z http://www.learntoprogramnow.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with a small piece of code (New to VB) kwik10z Excel VBA 2 October 12th, 2007 06:46 AM
small problem with cookies Paula222 ASP.NET 2.0 Professional 0 May 25th, 2007 02:08 AM
small problem with cookies Paula222 ASP.NET 2.0 Basics 0 May 25th, 2007 02:05 AM
Beginning VB6.0 Small Problem kalaiselvi Beginning VB 6 3 April 11th, 2005 01:24 PM
small problem harjinder_x XSLT 0 March 23rd, 2004 05:43 AM



All times are GMT -4. The time now is 12:05 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.