Consulting

Results 1 to 2 of 2

Thread: Retrieve data from Access

  1. #1
    VBAX Newbie
    Joined
    Jul 2013
    Posts
    1
    Location

    Post Retrieve data from Access

    I new to vba....

    Sub SelectMonth()
    ' Variable Declaration
    Dim i As Integer
    Dim SelectSQL As String, WhereSQL As String
    Dim Stamp As String, text As String, datacnt1 As Integer

    Set dbsc = OpenDatabase(Systempath)


    datacnt1 = 0
    x1 = 10
    y1 = 10
    x2 = 10
    y2 = 11
    x3 = 10
    y3 = 12
    x4 = 10
    y4 = 13
    x5 = 10
    y5 = 14
    w1 = 0
    w2 = 0
    w3 = 0
    w4 = 0
    w5 = 0
    i = 1


    ' Build SQL Text
    SelectSQL = ""
    SelectSQL = "SELECT Month FROM WK "

    'SelectSQL = SelectSQL
    Set dnset1 = dbsc.OpenRecordset(SelectSQL)

    datacnt1 = dnset1.RecordCount




    ' Dyanset Move First Position
    dnset1.MoveFirst

    Do While dnset1.EOF = False

    If IsNull(dnset1.Fields(0)) Then

    Else
    Cells(x1, y1) = dnset1.Fields(0)
    x1 = x1 + 1
    'w1 = w1 + 1
    'SelectDistrictName
    'SelectNewCountryCode
    'SelectCatType
    'SelectMaterial

    End If

    dnset1.MoveNext
    Loop

    GoTo SelectDynasetClose

    SelectDynasetClose:
    dnset1.Close

    End Sub





    The records all print first value. If print second records it show runtime error 3265. Items not found this collection

    Thanks in advance....

  2. #2
    VBAX Contributor
    Joined
    Feb 2009
    Posts
    103
    Location
    check out this link:
    it might give you an idea on how to get the thing done.

    http://support.microsoft.com/kb/306125/en-us

Posting Permissions

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