CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: bookmarks

  1. #1
    Join Date
    Feb 2000
    Location
    Indiana USA
    Posts
    193

    bookmarks

    I am having trouble with Bookmarks, this is the first time I have attempted to use them. I have a table that holds multiple entries for each employee. I open the recordset that fill text boxes with the data all on one screen. If an item needs changed, I am having a problem, I get the error "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another". Perhaps I am going about this the wrong way. Basicly what I need is a way to display multiple records and update the records if the user makes a change.Any advice would be appreciated. Thanks in advance.
    Catrina
    Here is my code:

    ''Opening the recordset with all records for the needed employee
    set rsDirect = new ADODB.Recordset
    SQL$ = ""
    SQL$ = "SELECT * FROM DirectDeposit WHERE PAYEMP='"
    SQL$ = SQL$ & text(0).text & "' Order By Tran asc"
    rsDirect.Open SQL$, Access, adOpenKeyset, adLockOptimistic
    ''''filling the textboxes with the data
    TranNo$ = ""
    If Not rsDirect.EOF then
    rsDirect.MoveFirst
    for a% = 1 to rsDirect.RecordCount
    If rsDirect!Tran <> "N" then
    '''setting the variable holding the bookmark
    DDBook(a%) = rsDirect.Bookmark
    BX% = Val(rsDirect!Tran) ''Tran tells which line the data is going to
    txtDed(BX%).text = rsDirect!Ded
    txtTran(BX%).text = rsDirect!Code
    txtAccount(BX%).text = rsDirect!Account
    txtRoute(BX%).text = rsDirect!Route
    else
    DDBook(a%) = rsDirect.Bookmark
    txtTran(0).text = rsDirect!Code
    txtAccount(0).text = rsDirect!Account
    txtRoute(0).text = rsDirect!Route
    End If
    rsDirect.MoveNext
    next a%
    End If

    ''trying to change the data
    stAcc$ = mid(lblAcc(Index).Caption, 2) & Left(ZOUT$ & Space(17), 17)
    rsDirect.Bookmark = DDBook(Index) ''I get the error here
    rsDirect!Account = mid(stAcc$, 4)
    rsDirect.Update





  2. #2
    Join Date
    Jun 2001
    Location
    Memphis, TN
    Posts
    146

    Re: bookmarks

    Maybe I'm analyzing the wrong problem, but in your second SQL line you put the single quote for commentation before the double quote to end the string. Is it that way in your actual code or just a typo in your post?


  3. #3
    Join Date
    Feb 2000
    Location
    Indiana USA
    Posts
    193

    Re: bookmarks

    When using Access, string data must be surrounded by 's (ex:"'" & text.text & "'") in the SQL statement. The way this board displays it makes it look incorrect. I'm fine with opening the recordset, it is the update I'm having trouble with.

    Catrina


  4. #4
    Join Date
    May 2001
    Location
    UK
    Posts
    11

    Re: bookmarks

    Is your array DBook() a variant array? There's no 'Dim' for it in your post, and because you're setting its size there and then without using ReDim I guess that DBook isn't being declared earlier on.

    Do you still get the error if you explicitly declare DBook as a variant array, then use ReDim when you know the size of it?

    eg

    Dim DBook()
    .....
    ReDim DBook(a&)
    ...


  5. #5
    Join Date
    Feb 2000
    Location
    Indiana USA
    Posts
    193

    Re: bookmarks

    I have it defined as a Public Variant in a module. The size will always be 10, so I do not redim. When I step through, it contains the bookmark, but I still get the error.

    I have solved the problem by closing the original recordset, then opening a recordset according to the box they are currently in to make the update record by record. May be a wasteful way of doing it, but it works and I needed a fix fast.

    Thanks for your reply

    Catrina


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

Featured