Results 1 to 4 of 4
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329

    Formatting problem

    Hi Guy's can anyone help on this one i am finding rather bizarre!!


    Dim iSort as Integer

    iSort = "99"


    Set rs = CurrentDb.OpenRecordset("SELECT tblStock.SortNo, tblStock.PONumber, tblStock.LiftType, tblStock.LiftNo, tblStock.StartQty, tblStock.AllocatedQty, tblStock.NewQty FROM tblStock WHERE SortNo < " & iSort & " ORDER BY SortNo;")

    Although the iSort is set to integer and the field is set to long integer and the cells on the excel file template is set to Number with 0 decimals

    The sortNo cells are 01/01/1900 ?

    Can this be reformatted before the file gets exported to prevent another user accidentally sending in that format ?

    .Worksheets(1).Cells(3, 3).CopyFromRecordset rs
    '.Worksheets(1).Range("C3:C50").NumberFormat = "Number" SOMETHING LIKE THIS ????

    Much appreciated

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Try:

    .Worksheets(1).Range("C3:C50").NumberFormat = "0"
    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
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Hi June7, thank you i am going to try that and post back

    Kindest

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you can do an isnumeric check to verify the value is numeric then change it to a number (forcing it to be if MS Access is reading it as a string) with the CINT or CDBL.

    If you are defining iSort = "99" you are defining it as a string in your code

    Dim iSort

    iSort = 99

    the " marks will cause mayhem.

    You can also do

    Code:
    debug.print "SELECT tblStock.SortNo, tblStock.PONumber, tblStock.LiftType, tblStock.LiftNo, tblStock.StartQty, tblStock.AllocatedQty, tblStock.NewQty FROM tblStock WHERE SortNo < " & iSort & " ORDER BY SortNo;"


    to see how your SQL string looks before you try to execute it. I'll bet it's throwing ' or " marks around your isort value or your isort isn't what you think it is

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

Similar Threads

  1. Replies: 2
    Last Post: 11-12-2015, 10:46 AM
  2. Problem with conditonal formatting
    By FrustratedAlso in forum Programming
    Replies: 11
    Last Post: 06-01-2015, 11:09 PM
  3. Conditional Formatting Problem
    By baileysw in forum Access
    Replies: 2
    Last Post: 11-21-2012, 06:23 PM
  4. Formatting dates problem
    By ruthib4 in forum Programming
    Replies: 16
    Last Post: 02-25-2012, 12:49 AM
  5. Conditional Formatting Problem
    By DanKoz in forum Access
    Replies: 6
    Last Post: 10-23-2011, 12:57 AM

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