Hi Andreas
Thank you very much for your assistance - seems to be working really well for what I wanted
But :-( going back to my original problem that we discussed - that being the date issue - even though I added the relevant code to the form as below for editing the data already saved in the work sheet
Me.txtdate.Value = Format(Me.LstDatabase.List(Me.LstDatabase.ListIndex, 17), "dd/mm/yyyy")
which is an entry in the code controlled by the command button as per the code below
Private Sub cmdedit_Click()
If Selected_List = 0 Then
MsgBox "No Row is Selected.", vbOKOnly + vbInformation, "Edit"
Exit Sub
End If
'Code to update the value to respective controls
Me.txtRowNumber.Value = Application.WorksheetFunction.Match(Me.LstDatabase.List(Me.LstDatabase.ListIndex, 0), _
ThisWorkbook.Sheets("Database").Range("A:A"), 0) 'Selected_List + 1
So this resolved the issue of when the data is returned to the user form - where the txtdate box was showing a text number
So now all data on the worksheet is saved in UK format dd/mm/yyyy as you pointed out - so now there are no text formatting of dates or times in the worksheet
The problem is that it seems that user form txtdate value, on saving to the worksheet is being saved in mm/dd/yyyyy format - ive double checked all the settings to make sure regional and excel formatting is correct but I cant resolve this issue. One thing
however is that if the date is changed by editing the worksheet directly, the format stays correct - when returning the data back to the user form for editing - so to me it seems that the format of the txtdate value on the user form is not being saved from
the user form to the worksheet - would you agree?
this is the relevant code
Sub Submit()
Dim sh As Worksheet
Dim irow As Long
Set sh = ThisWorkbook.Sheets("Database")
If frmincident.txtRowNumber.Value = "" Then
irow = [Counta(Database!A:A)] + 1
Else
irow = frmincident.txtRowNumber.Value
End If
With sh
.Cells(irow, 1) = "=Row()-2" 'Dynamic Serial Number
.Cells(irow, 2) = frmincident.txtcomment.Value
.Cells(irow, 3) = frmincident.cmbdelay.Value
.Cells(irow, 5) = frmincident.txtfinished.Value
.Cells(irow, 7) = frmincident.txtarrival.Value
.Cells(irow, 9) = frmincident.txtturnout.Value
.Cells(irow, 11) = frmincident.txtdispatch.Value
.Cells(irow, 12) = frmincident.cmbproperty.Value
.Cells(irow, 13) = frmincident.cmbincident.Value
.Cells(irow, 14) = frmincident.cmbcommunity.Value
.Cells(irow, 15) = frmincident.cmbstation.Value
.Cells(irow, 16) = frmincident.cmbcall.Value
.Cells(irow, 17) = frmincident.txttime.Value
.Cells(irow, 18) = frmincident.txtdate.Value
.Cells(irow, 19) = frmincident.txtautomax.Value
.Cells(irow, 20) = Application.UserName
.Cells(irow, 21) = [Text(Now(),"DD-MM-YYYY HH:MM:SS")]
End With
End Sub
Can you help me with this please? can I add some formatting within the lines irow5 and 18 or do we do it by adding code to the textbox?
PS if you are getting errors because of the arabic text you should change the regional setting for the non unicode to arabic - sorry if you already know that
Thank you
Adrian