Getchunk : argument not optional error

Posted on 2005-05-06
Last Modified: 2013-12-25
I am getting the error 'argument not optional' on line 'bytes() = rs(PFName).GetChunk(Block_Size)' with 'getchunk' highlighted as the error. I took this code from another site so i assume i've not defined something correctly but i don't know what ! Can anyone offer any suggestions ?

Public Sub FillPhoto(rs As Recordset, PFName As String, SizeField As String, Picture1 As PictureBox)
On Error GoTo Handler
Dim bytes() As Byte
Dim file_name As String
Dim file_num As Integer
Dim file_length As Long
Dim num_blocks As Long
Dim left_over As Long
Dim block_num As Long
Dim hgt As Single

    'me.imgPhoto.Visible = False
    Screen.MousePointer = vbHourglass

    ' Get a temporary file name.
    file_name = TemporaryFileName()

    ' Open the file.
    file_num = FreeFile
    Open file_name For Binary As #file_num

    ' Copy the data into the file.
    file_length = rs(SizeField)
    num_blocks = file_length / Block_Size
    left_over = file_length Mod Block_Size

    For block_num = 1 To num_blocks
        bytes() = rs(PFName).GetChunk(Block_Size)
        Put #file_num, , bytes()
    Next block_num

    If left_over > 0 Then
        bytes() = rs(PFName).GetChunk(left_over)
        Put #file_num, , bytes()
    End If

    Close #file_num

    Picture1.Picture = LoadPicture(file_name)
    Screen.MousePointer = vbDefault
Exit Sub

    Debug.Print Err.Description
    Resume Next
End Sub
Question by:wouldbeguru
    1 Comment
    LVL 33

    Accepted Solution

    How To Use GetChunk and AppendChunk Methods of RDO and ADO Object;en-us;153238

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now