Hi all,
Firstly please accept my apologies if i am breaking some kind of forum rule by posting this question here. But i am hoping that the same principle will apply for VB as for VBA on this one.

I have a small issue with a date format in my Excel 2002 forms. When i select a date from a drop down list (formatted as date in excel sheet) the form shows the number value for that date not the date itself. I am aware how to format the date in normal worksheets but unaware of how to do this for a form field. Please help as its been bugging me all morning.

Below is the code when the field changes.

Private Sub CBPrposedDate_Change()
Call dater
End Sub

Sub dater()
Dim banana As Date
If FRMAgent_Details.CBAreaOfBus = "Sales" Then
banana = FRMAgent_Details.CBPrposedDate.Text
Sheets("InputForm").Select
Range("u2").Select
Do Until ActiveCell.Value = banana
ActiveCell.Offset(1, 0).Select
Loop
FRMAgent_Details.TBRequestDate.Text = ActiveCell.Offset(0, 3).Value
banana1 = FRMAgent_Details.TBRequestDate.Text
Sheets("Main").Select
Else
banana = FRMAgent_Details.CBPrposedDate.Text
Sheets("InputForm").Select
Range("u2").Select
Do Until ActiveCell.Value = banana
ActiveCell.Offset(1, 0).Select
Loop
FRMAgent_Details.TBRequestDate.Text = ActiveCell.Offset(0, 2).Value
banana1 = FRMAgent_Details.TBRequestDate.Text
End If
End Sub


Many thanks in advance for any help you may be able to offer.

Eddiesvoicebox

Hi,

Try setting a breakpoint at the beginning of the Dater sub and adding a watch to check out the values stored in the variables. If you want to check a date (without using the time part of the date) then try using the format function:

format(DateVariable,("DD/MM/YYYY"))


this will return the datevariable in the format suggested. If you do this to both sides of your comparison line then you will be comparing apples with apples.

Mark

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.