Hans,
I was wondering why you suggest that having 40 date picker fields may not be a good idea? It was the only way I could think of to solve my problem. I short, the aim of my application is for users to be able to send the information of their requested travel bookings to their travel agent. There is a need for at least 10 flight requests and 5 hotel and car bookings.
If there is an easier way I would be greatful of any advice.
I had previously tried to do a similiar thing using a Custom Form in Outlook but users found using Outlook a little difficult (believe it or not!).
Thanks heaps for your time.

Bill

2003-07-05, 10:16

HansV

Re: MonthView Control (VB6)

Bill,

It seems to me that one form with space for 10 flight requests, 5 hotel bookings and 5 car bookings with details for each will be rather cluttered. I haven't thought deeply about it, but I would probably create a form that presents a non-editable overview of the customer's bookings, with command buttons that show a popup form for editing an existing booking or adding a new one.

2003-07-05, 14:19

bnorthby

Re: MonthView Control (VB6)

Hans,
The code you kindly provided works up to a point. It blanks out all the fields as required and allows the date picker to be selected, however when I select the date, the field goes back to being blank. I had a go at solving the problem myself with some limited success.
The code at the end of this message, when added to the code you provided, enables the field to retain the date when it is selected from the date picker field. However it only works for one field (dtpDepDate1).
I don't really want to write the same code 40 times for the 40 fields that will have to be changed. Is there an easier way of doing this?
On the other issue of why so many fields, I have attached a screen shot which may offer a better explanation than I was able to offer.
Thanks as always.

Bill

Private Sub dtpDepDate1_CloseUp()
FormatDTPicker
End Sub

Private Sub dtpDepDate1_Format(ByVal CallbackField As String, _
FormattedString As String)
If CallbackField = "X" Then
FormattedString = ""
End If
End Sub

Private Sub FormatDTPicker()
With dtpDepDate1
If .Value = vbNull Then
.Format = dtpCustom
.CustomFormat = "X"
Else
.Format = dtpShortDate
End If
End With
End Sub

Private Sub dtpDepDate1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
With dtpDepDate1
If .Value = vbNull Then
.Value = Now
End If
End With

2003-07-05, 14:24

bnorthby

Re: MonthView Control (VB6)

Oops, sorry the attachment didn't make it last time. Another try.

2003-07-05, 15:36

HansV

Re: MonthView Control (VB6)

Hi Bill,

I didn't know that you had organized your form with a tab control; it looks good, I admit.

About the code: the Date/Time picker is not installed on the PC I'm using at the moment (neither is VB6), so I can't test code. You should be able to reduce the code for each of the events to one line, calling a generalized routine:

Private Sub dtpDepDate1_CloseUp()
FormatDTPicker 1
End Sub

Private Sub FormatDTPicker(i As Integer)
With Me.Controls("dtpDepDate"& i)
If .Value = vbNull Then
.Format = dtpCustom
.CustomFormat = "X"
Else
.Format = dtpShortDate
End If
End With
End Sub

Private Sub HandleMouseDown(i As Integer)
With Me.Controls("dtpDepDate" & i)
If .Value = vbNull Then
.Value = Now
End If
End With
End Sub

Another remark: have you tried to use control arrays?

2003-07-05, 15:53

bnorthby

Re: MonthView Control (VB6)

Hans,
Thanks for that. I am away from my normal PC at the moment so I won't be able to test your code until tomorrow. I will let you know how I go.
As for control arrays, I must admit I have read a bit about them but have the confidence to use them. Is it in my interests to do so?
Appreciate your help.

Bill

2003-07-05, 16:09

HansV

Re: MonthView Control (VB6)

Bill,

Instead of independent controls dtpDepDate1 to dtpDepDate10, you could have 10 controls all named dtpDepDate, with index 1 through 10. The controls in a control array share event procedures, so you don't have to write 10 individual routines for each event.

2003-07-06, 02:35

bnorthby

Re: MonthView Control (VB6)

Hans - Your explanation is much clearer than the books I have been reading. I understand now and will look at it. Thanks heaps.

Bill

2003-07-06, 06:55

bnorthby

Re: MonthView Control (VB6)

Hi Hans,
I have installed the code and still no go:-( The date picker field works for field dtpDepDate1 as it is supposed to but for the remaining fields the field does not retain the value once selected.
I have taken the liberty of attaching all of the code as it now exists to see if you can see where the problem is. I have looked without success.
Thanks heaps for your time.

You see that you still need to create event handlers for all controls, but you don't have to copy multiple lines of code into each, you just call a common routine. If you were to use control arrays, this wouldn't be necessary. As I wrote, the items in a control array use shared event handlers.

2003-07-07, 04:48

bnorthby

Re: MonthView Control (VB6)

Hans,
So far, so good. The code works fine for the dtpDepDate fields. I tried to adapt the code for the remaining fields one by one and the code continually stops in the first line of the following code: I get an ambigous name detected message.

Private Sub FormatDTPicker(i As Integer)
With Me.Controls("dtpArrDate" & i)
If .Value = vbNull Then
.Format = dtpCustom
.CustomFormat = "X"
Else
.Format = dtpShortDate
End If
End With
End Sub

As this thread is getting a little long I have attached the whole code as it currently is as a .txt file to this message.
Thanks heaps.

Bill

2003-07-07, 06:08

HansV

Re: MonthView Control (VB6)

Bill,

You asked the same question in <post#=269268>post 269268</post#>, so you'll get the same answer: <post#=269403>post 269403</post#>.