Results 1 to 7 of 7
  1. #1
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37

    Reading in a number formatted as a string from a PDF form

    Hi All,



    I am having a slight issue, and I hope someone can help me resolve this.

    I made a PDF form, and I use a button on my Access form to read in the PDF fields into my database.

    I saved the value "00300" into the PDF form, under the field name "DOC NO". When I open the PDF form file, I see that 00300 is actually in there.

    BUT, when I read in the value into a string, I get "300" instead of "00300".

    I used this code to read in the value:

    currentPartNum = jso.getField("DOC NO").value

    Where currentPartNum is a string and jso is a object.

    So, my question:
    Is there another field under getField (instead of value) that will give me the full string and not just the number?
    Or was I supposed to change a setting in the PDF form so that it thinks the field is a string and not a number?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I doubt the Value property has anything to do with the truncation of leading zeros. Value is probably default property which means could likely not even reference it and the output would be the same.

    Is currentPartNum variable explicitly declared as a String type?
    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
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37
    Hi,

    Yup I declared currentPartNum as

    Dim currentPartNum As String

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Do you always want a 5-digit string?

    Try:

    currentPartNum = Format(jso.getField("DOC NO").Value, "00000")
    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.

  5. #5
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37
    Yeah, I thought about doing that.

    The field holds a part number. In general it is 5-digits, but in a rare instance it could be longer or shorter, so I want to find a way where it doesn't drop the leading zeros.

  6. #6
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37
    I found my answer, apparently using Value is wrong...instead, I did

    currentPartNum = jso.getField(temp).valueAsString

    And all works well

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Okay, Value property did have something to do with this issue - it was wrong property. Glad you found solution and thanks for sharing it.
    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.

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

Similar Threads

  1. Extract number from String
    By DOSRoss in forum Programming
    Replies: 26
    Last Post: 04-28-2015, 06:07 AM
  2. Extract a number from a string
    By webisti in forum Access
    Replies: 3
    Last Post: 09-16-2013, 08:29 AM
  3. Replies: 0
    Last Post: 10-22-2012, 02:45 PM
  4. Replies: 12
    Last Post: 02-22-2011, 03:39 PM
  5. Replies: 1
    Last Post: 02-22-2011, 03:05 PM

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