Results 1 to 5 of 5

Thread: VB6 Access 2007 using SEEK (after convert mdb to accdb)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2012
    Posts
    8

    Resolved VB6 Access 2007 using SEEK (after convert mdb to accdb)

    vb Code:
    1. 'Code sample vb6 connecting with Ms-Access 2007/2010
    2. 'Exemplo vb6 conectando com Ms-Access 2007/2010
    3.  
    4. '--------------------------------------------------------
    5. Global sDirInstall
    6. Global sMyDB As String
    7. Global sMyDBVENDAS As String
    8. '---------------------------------------------------------
    9. Sub UserInfo()
    10.    
    11. 'PROJECT -> REFERENCE: Microsoft ActiveX Data Objects 2.8 Library
    12.  
    13.     Dim con As ADODB.Connection
    14.     Dim rs As ADODB.Recordset
    15.    
    16.     Set con = New ADODB.Connection
    17.     Set rs = New ADODB.Recordset
    18.    
    19.     sDirInstall = App.Path
    20.     sMyDB = sDirInstall & "\USER.accdb"
    21.     con.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & sMyDB & ";Persist Security Info=False;Jet OLEDB:Database Password="
    22.  
    23.     rs.Index = "Primarykey"
    24.     rs.CursorLocation = adUseServer
    25.     rs.Open ("tb_User"), con, adOpenDynamic, adLockOptimistic, adCmdTableDirect
    26.  
    27.     Do While Not rs.EOF
    28.         MsgBox rs.Fields("Userid") & " - " & rs.Fields("Nome")
    29.         rs.MoveNext
    30.     Loop
    31.    
    32.     rs.Seek Array("NewUser"), adSeekFirstEQ
    33.     If rs.EOF Then
    34.         rs.AddNew
    35.         rs.Fields("Userid") = "NewUser"
    36.         rs.Fields("Nome") = "USER NEW"
    37.         rs.Update
    38.         MsgBox "1 user added!"
    39.     Else
    40.         rs.Fields("Nome") = "USER NEW " & Now()
    41.         rs.Update
    42.         MsgBox "1 user changed!"
    43.     End If
    44.     rs.Close
    45.     con.Close
    46. End Sub

    Good Lucky!
    Boa Sorte!
    Last edited by si_the_geek; Jan 7th, 2012 at 05:24 AM. Reason: added Code tags

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: VB6 Access 2007 using SEEK (after convert mdb to accdb)

    Is this a demonstration project or a project you are having trouble with? Could you please wrap your code in [highlight="vb"][/highlight] to make it easier to read.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2012
    Posts
    8

    Resolved Re: VB6 Access 2007 using SEEK (after convert mdb to accdb)

    Quote Originally Posted by Nightwalker83 View Post
    Is this a demonstration project or a project you are having trouble with? Could you please wrap your code in [highlight="vb"][/highlight] to make it easier to read.


    Hi Nightwalker83 !

    This a demonstration project to help who needs to upgrade vb6 code using new MS database format accdb.


    Regards,

    HENDELCWB

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: VB6 Access 2007 using SEEK (after convert mdb to accdb)

    In that case I will request it moved to the code bank.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: VB6 Access 2007 using SEEK (after convert mdb to accdb)

    Welcome to VBForums

    Thread moved from the 'VB6 and earlier' forum (which is for questions) to the 'CodeBank VB6' forum (which is for working examples)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width