I have a spreadsheet that work fine but there are two problems.
1. is that the is a problem with a cell in my user form for the date. If i type the date in a 13-Mar-2005 it will work fine. It will also work fine if i type in a date that is recent. The problem arrises if i type the date as 13/03/2005 it will change it to 03/13/2005 when it is pasted from the userform into the spreadsheet. It is not plausable for an imputter to have to always type the date in as 13-Mar-2005 but I am not sure what is wrong with my code to make it convert it to an american date. The code that i have used for this is.
Private Sub cmd_save_Click()
' This is used to move the record to the spreadsheet and
' create a new record
'Commandbutton used to save the new record to the worksheet
lstRow = Worksheets("database").Ran
ge("c65536
").End(xlU
p).Row + 1
With Worksheets("database")
.Range("c" & lstRow).Value = Me.frm_representative.txt_
caseworker
.Text
.Range("d" & lstRow).Value = Me.frm_representative.txt_
company.Te
xt
.Range("e" & lstRow).Value = Me.frm_reference.txt_refer
enceno1.Te
xt
.Range("f" & lstRow).Value = Me.frm_reference.txt_refer
enceno2.Te
xt
.Range("g" & lstRow).Value = Me.frm_post_type.cbo_post_
type.Text
.Range("h" & lstRow).Value = Me.frm_date.txt_receipt_da
te.Text
.Range("j" & lstRow).Value = Me.frm_action_taken.cbo_ac
tion_taken
.Text
Me.frm_representative.txt_
caseworker
.Text = ""
Me.frm_representative.txt_
company.Te
xt = ""
Me.frm_reference.txt_refer
enceno1.Te
xt = ""
Me.frm_reference.txt_refer
enceno2.Te
xt = ""
Me.frm_post_type.cbo_post_
type.Text = ""
Me.frm_date.txt_receipt_da
te.Text = ""
Me.frm_action_taken.cbo_ac
tion_taken
.Text = ""
MsgBox "Postal Record Entered Successfully"
End With
End Sub
My second problem is that i got help from here on a forward and back button but they do not seem to work properly. I am sure that it is something that i have coded wrong but i seems to search from the bottom but when you go to look for other information that is the same it does not work properly
my code for this is
Search Button
Private Sub cmd_search_Click()
On Error GoTo dRecordNotFound
With Worksheets("Database")
lstRow = Worksheets("Database").Ran
ge("C65536
").End(xlU
p).Row + 1
Set Rng = .Range("F1:F" & lstRow).Find(Me.frm_refere
nce.txt_re
ferenceno2
.Text)
Me.frm_representative.txt_
caseworker
.Text = .Range("c" & Rng.Row).Value
Me.frm_representative.txt_
company.Te
xt = .Range("d" & Rng.Row).Value
Me.frm_reference.txt_refer
enceno1.Te
xt = .Range("e" & Rng.Row).Value
Me.frm_reference.txt_refer
enceno2.Te
xt = .Range("f" & Rng.Row).Value
Me.frm_post_type.cbo_post_
type.Text = .Range("g" & Rng.Row).Value
Me.frm_date.txt_receipt_da
te.Text = .Range("h" & Rng.Row).Value
Me.frm_date.txt_receipt_da
te.Text = .Range("h" & Rng.Row).Value
Me.frm_action_taken.cbo_ac
tion_taken
.Text = .Range("j" & Rng.Row).Value
Worksheets("Database").Act
ivate
Worksheets("Database").Ran
ge("c" & Rng.Row).Activate
End With
Exit Sub
dRecordNotFound:
MsgBox "The record was not found"
On Error GoTo 0
End Sub
Next Button
rivate Sub cmd_next_Click()
With Worksheets("Database")
lstRow = lstRow + 1
If .Range("C" & lstRow).Value = "" Then
MsgBox "You have reached the last record"
Exit Sub
End If
Me.frm_representative.txt_
caseworker
.Text = .Range("c" & lstRow).Value
Me.frm_representative.txt_
company.Te
xt = .Range("d" & lstRow).Value
Me.frm_reference.txt_refer
enceno1.Te
xt = .Range("e" & lstRow).Value
Me.frm_reference.txt_refer
enceno2.Te
xt = .Range("f" & lstRow).Value
Me.frm_post_type.cbo_post_
type.Text = .Range("g" & lstRow).Value
Me.frm_date.txt_receipt_da
te.Text = .Range("h" & lstRow).Value
Me.frm_date.txt_post_age.T
ext = .Range("h" & lstRow).Value
Me.frm_action_taken.cbo_ac
tion_taken
.Text = .Range("j" & lstRow).Value
End With
End Sub
Back Button
Private Sub cmd_back_Click()
With Worksheets("Database")
lstRow = lstRow - 1
If lstRow = 1 Then
lstRow = 2
Exit Sub
End If
Me.frm_representative.txt_
caseworker
.Text = .Range("c" & lstRow).Value
Me.frm_representative.txt_
company.Te
xt = .Range("d" & lstRow).Value
Me.frm_reference.txt_refer
enceno1.Te
xt = .Range("e" & lstRow).Value
Me.frm_reference.txt_refer
enceno2.Te
xt = .Range("f" & lstRow).Value
Me.frm_post_type.cbo_post_
type.Text = .Range("g" & lstRow).Value
Me.frm_date.txt_receipt_da
te.Text = .Range("h" & lstRow).Value
Me.frm_date.txt_post_age.T
ext = .Range("i" & lstRow).Value
Me.frm_action_taken.cbo_ac
tion_taken
.Text = .Range("j" & lstRow).Value
End With
End Sub
Start Free Trial