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
Bookmarks