+ Reply to Thread
Results 1 to 3 of 3

Date not formatted properly

Hybrid View

nathan.volker12 Date not formatted properly 08-16-2018, 12:24 PM
xlnitwit Re: Date not formatted... 08-16-2018, 12:26 PM
nathan.volker12 Re: Date not formatted... 08-16-2018, 12:28 PM
  1. #1
    Registered User
    Join Date
    08-13-2018
    Location
    taylor mill, kentucky
    MS-Off Ver
    2010
    Posts
    61

    Date not formatted properly

    Can someone help me with this code. It works fine, that's not the issue. The issue is that it is putting my date as a text format and causing further issues.
    Near the bottom I have listed the exact line that is causing the issues and I don't know how to change the code to format it differently.

    Private Sub cmdAdd_Click()
    'Dim the Variable
        Dim DataSH As Worksheet
        Dim Addme As Range
    'Set the Variable
        Set DataSH = Sheet1
    'Error Handler
        On Error GoTo errHandler:
    'Set Variable for the Destination
        Set Addme = DataSH.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0)
    'Hold in memory and stop screen flicker
        Application.ScreenUpdating = False
        If Me.txtTruck = "" Or Me.txtDate = "" Or Me.TxtService = "" Then
        MsgBox "There is insufficient data, Please return and add the needed information"
            Exit Sub
        End If
    'Send the value to the Database
        With DataSH
    'Add the unique reference ID and then all other variables
            Addme.Offset(0, -1) = DataSH.Range("C6").Value + 1
            Addme.Value = Me.txtTruck
            Addme.Offset(0, 1).Value = Me.txtDate
            Addme.Offset(0, 2).Value = Me.TxtService
        End With
    'Sort the data by Truck Number
        DataSH.Select
        With DataSH
            .Range("B9:F10000").Sort Key1:=Range("C9"), Order1:=xlAscending, Header:=xlGuess
        End With
    'Clear the values after entry
        Clear
    'Communicate with the user
        MsgBox "Your Data was successfully added"
    'Return to interface sheet
        Sheet2.Select
    'Reset the form
        On Error GoTo 0
        Exit Sub
    errHandler:
    'If error occurs then show me exactly where the error occurs
        MsgBox "Error " & Err.Number & _
                " (" & Err.Description & ")in procedure cmdClear_Click of Form MaintDB"
     
    End Sub
    Specifically this line
    Addme.Offset(0, 1).Value = Me.txtDate

    So that it can be properly formatted as a date instead of text




    I have this in another forum on this site that has been ongoing for quite sometime with user rorya but she went offline and this is urgent for me.
    https://www.excelforum.com/excel-pro...es-help-2.html this is the other post that has been ongoing. If someone can help me I will make sure to close them out

    Thank you so much in advance

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Date not formatted properly

    Use:

    Addme.Offset(0, 1).Value = cdate(Me.txtDate)
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    08-13-2018
    Location
    taylor mill, kentucky
    MS-Off Ver
    2010
    Posts
    61

    Re: Date not formatted properly

    Thank you so much

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Convert text-formatted date to regular date
    By jwengiel in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-03-2017, 06:04 PM
  2. Text formatted as date
    By wpryan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2015, 02:22 PM
  3. Sorting "" properly for date formatted column
    By TheGunslinger in forum Excel General
    Replies: 6
    Last Post: 05-06-2015, 06:06 PM
  4. Replies: 4
    Last Post: 09-19-2014, 11:26 AM
  5. Date of last row formatted
    By Xx7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2011, 06:14 PM
  6. Replies: 5
    Last Post: 02-02-2010, 05:01 AM
  7. date formatted in text
    By Clash in forum Excel General
    Replies: 3
    Last Post: 06-30-2007, 05:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1