Results 1 to 7 of 7
  1. #1
    Kundan is offline Competent Performer
    Windows XP Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    155

    Thumbs down Error

    'On Error GoTo TowardsError
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset2
    Dim temp

    'Get the database, recordset, and attachment field
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("SELECT ALLOCATION, AMOUNTs, REMARKS FROM [DEPARTMENT & ALLOCATION] WHERE [CR NO]='" & CRNO & "'")


    Do Until rst.EOF
    'For each item, get the Allocation and Amount details.
    9 temp = temp & rst("ALLOCATION") & " Rs." & rst("AMOUNTs") & " " & rst("REMARKS") & "; "
    'MsgBox Temp
    ' Move to the next order item (if there is one).
    15 rst.MoveNext
    16 Loop
    'MsgBox (Len(temp) - 2)
    Stuff([temp], CharIndex('; ', [temp]), Len('; '), '. ')
    'Assign value to function
    TWARDS = temp
    17 rst.Close
    18 CurrentDb.Close
    Exit Function
    TowardsError:
    ' You only get here if an error occurred.
    ' Show the error.
    21 MsgBox Err.Number
    MsgBox Err.Description

    End Function



    The above code giving error at the stuff function.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Either comment out the On Error line or set a breakpoint and step through code so you can get a real error message.

    What is the code for Stuff() and CharIndex()? Why use Len() function on a string of known length?

    Should post code between CODE tags to retain indentation and readability.
    Last edited by June7; 02-15-2019 at 04:40 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    I would also add - to June's request - what is the error description

  4. #4
    Kundan is offline Competent Performer
    Windows XP Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    155
    Quote Originally Posted by June7 View Post
    Either comment out the On Error line or set a breakpoint and step through code so you can get a real error message.

    What is the code for Stuff() and CharIndex()? Why use Len() function on a string of known length?

    Should post code between CODE tags to retain indentation and readability.

    It is giving Syntax error.

    My goal is to replace the last "; " in the string temp with ". ". How to achieve it?

  5. #5
    Kundan is offline Competent Performer
    Windows XP Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    155
    Quote Originally Posted by Ajax View Post
    I would also add - to June's request - what is the error description

    It is giving Syntax error.

    My goal is to replace the last "; " in the string temp with ". ". How to achieve it?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    This line:

    Stuff([temp], CharIndex('; ', [temp]), Len('; '), '. ')

    makes no sense.

    Instead:

    temp = Left(temp, Len(temp)-2) & "."
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Kundan is offline Competent Performer
    Windows XP Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    155
    Quote Originally Posted by June7 View Post
    This line:

    Stuff([temp], CharIndex('; ', [temp]), Len('; '), '. ')

    makes no sense.

    Instead:

    temp = Left(temp, Len(temp)-2) & "."

    Thanks a Lot! GOD BLESS YOU!!!!!!!!!!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-22-2016, 05:05 AM
  2. Replies: 1
    Last Post: 07-26-2016, 06:34 AM
  3. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  4. Replies: 0
    Last Post: 07-16-2012, 05:42 AM
  5. Replies: 6
    Last Post: 05-30-2012, 12:32 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums