-
Date Field In Vb6 Programme
Hello there,
I am using a programme written in VB6 and I want to change a simple text field to a date field (I have no knowledge on VB or any other language, I can simply make easy changes to this programme).
What I would like is to have a drop-down menu in its place with the following properties (when clicked):
1. have nothing ("") as a start value
2. show dates (as a list) like this: 06 March 2006, Monday
3. always show today's date as a starting value (not the days before that)
4. when a value is selected other than the start value ("") a reminder should pop up (this reminder already exists so all that needs to be done here is call this: frmSetReminder1.Show
Is that possible to make? If yes, where can I find info on how to do this?
Thank you for everything,
Gina
-
Re: Date Field In Vb6 Programme
How many consequtive days should be in your dropdown?
-
Re: Date Field In Vb6 Programme
All year's dates. This is a programme for my travel agency that works all year round.
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by georgina
All year's dates. This is a programme for my travel agency that works all year round.
Do you want Jan 1st to Dec 31st or a rolling twelve months worth of dates?
-
Re: Date Field In Vb6 Programme
Try to find DTPicker, thats what you looking for.
Add from Components Microsoft Windows Common Controls 2 6.0
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by oh1mie
Try to find DTPicker, thats what you looking for.
Add from Components Microsoft Windows Common Controls 2 6.0
I was going to suggest this until I read this
Quote:
Originally Posted by georgina
3. always show today's date as a starting value (not the days before that)
I dont think she wants days prior to today to be available selections. (I could be wrong)
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by Hack
I was going to suggest this until I read thisI dont think she wants days prior to today to be available selections. (I could be wrong)
This was give me permit to recommend DTPicker:
(I have no knowledge on VB or any other language, I can simply make easy changes to this programme)
-
Re: Date Field In Vb6 Programme
Yes, that's it.
But what would be ideal is that I have each day's date and not previous ones. Is it possible to have +12 months from each day's date?
Thank you for everything.
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by oh1mie
This was give me permit to recommend DTPicker:
(I have no knowledge on VB or any other language, I can simply make easy changes to this programme)
you are 100% correct
-
Re: Date Field In Vb6 Programme
Welcome to the forums by the way. :wave:
Quote:
Originally Posted by georgina
Yes, that's it.
But what would be ideal is that I have each day's date and not previous ones. Is it possible to have +12 months from each day's date?
Thank you for everything.
Yes. It is called a "rolling tweleve months"
VB Code:
Private Sub Form_Load()
Dim i As Long
'enter todays date
Combo1.AddItem Format(Now, "long date")
'now add the remaining 365 dates for a
'rolling calendar year
For i = 1 To 365
Combo1.AddItem Format(Now + i, "long date")
Next
'set default to todays date
Combo1.ListIndex = 0
End Sub
-
Re: Date Field In Vb6 Programme
If, however, select an option today (06 March 2006, Monday) and open the programme in 2 days from today, then the same value originaly inserted should appear. It is only by clicking on the menu that value should be subject to change.
Do I make any sense? If not, please feel free to suggest a better way of doing this.
-
Re: Date Field In Vb6 Programme
Now function is picking everytime date and time from computers clock
-
Re: Date Field In Vb6 Programme
I think we may be talking about two different things here.
The dropdown with the rolling 12 months is something that would be used when creating a new record.
If you need to display and existing record, then you wouldn't be selecting anything unless you needed to change something previously saved.
So, for what purpose are you going to be using this dropdown?
Adding new records?
Changing existing records?
-
Re: Date Field In Vb6 Programme
Can I use another name for this as there is already a
Private Sub Form_Load()
that is used to load a setting.mdb database?
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by Hack
I think we may be talking about two different things here.
The dropdown with the rolling 12 months is something that would be used when creating a new record.
If you need to display and existing record, then you wouldn't be selecting anything unless you needed to change something previously saved.
So, for what purpose are you going to be using this dropdown?
Adding new records?
Changing existing records?
Let me describe why I want this in detail. Here is the procedure:
1. I open a request for a new client. At this stage I must have an empty filed as the default value.
2. I request from the hotel a date until which the owner will be holding the room for me, so I click on the drop-down menu and select a date. Date is saved in the database.
3. Later on I might want to alter the value of this field so I click on it again and select another date.
It seems more practical at the moment if another form is loaded everytime I click on the text box. So I guess we can leave the text box as it is and once clicked we can load a form that will have a selection of dates as we previously described.
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by georgina
Can I use another name for this as there is already a
Private Sub Form_Load()
that is used to load a setting.mdb database?
You can have more than one thing in a Form_Load. Some of my form load code goes on for miles. :)
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by georgina
It seems more practical at the moment if another form is loaded everytime I click on the text box. So I guess we can leave the text box as it is and once clicked we can load a form that will have a selection of dates as we previously described.
Based on what you have said, that would make sense.
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by Hack
Based on what you have said, that would make sense.
So I can have this:
Private Sub txtxtext2_Change(Index As Integer)
frmnewform.Show
End Sub
but what kind of data do I insert in this new frmnewform.frm?
Can I add both a set of dates and the standard empty field that I want? I wouldn't mind is they were in different drop-down menus (in the same form). No problem with that at all.
-
Re: Date Field In Vb6 Programme
First, put your .Show code in the click event of the combo, not the Change event.
Second, providing you have the cooresponding fields in your database (and I assume you do) then you cetaintly can both sets of dates, and it would make sense to have them in two separate combos.
-
Re: Date Field In Vb6 Programme
So I now have:
Private Sub txtxtext2_Click(Index As Integer)
frmnewform.Show
End Sub
This txtxtext2 is an array field and it is stored in my database.
What do I have to do with this frmnewform.frm (after I create it of course)?
I can definately create 2 combo boxes, one with standard preset values and the other one with dates. The problems nop are:
1. How do I create the date combo with the specifications described above?
2. How do I make the selected values being stored in my txtxtext2 text box?
Any ideas?
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by georgina
1. How do I create the date combo with the specifications described above?
If you mean how do you display what has been previously saved, then use the Text property of the combo box. When you query your database for a record, how do you do that?
Quote:
Originally Posted by georgina
2. How do I make the selected values being stored in my txtxtext2 text box?
VB Code:
Private Sub Combo1_Click()
Text1.Text = Combo1.Text
-
Re: Date Field In Vb6 Programme
What I have right now is the following:
1. My main form text box (where date should appear):
Private Sub txtxtext2_Click(Index As Integer)
frmoptiondate.Show
End Sub
2. My new frmoptiondate.frm with the combo as described above by you and shows dates starting from today (my only problem is that date is in Greek).
3. and this code:
Private Sub Combo1_Click()
frmMain.txtxtext2(Index).Text = Combo1.Text
End Sub
to make sure that combo1 value goes to my frmMain.txtxtext2(Index).Text but it doesn't. How can I make this drop-down menu insert its value to the text field in the other form (frmMain)?
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by georgina
to make sure that combo1 value goes to my frmMain.txtxtext2(Index).Text but it doesn't. How can I make this drop-down menu insert its value to the text field in the other form (frmMain)?
Instead of using Index, try specifying the actual index number.
-
Re: Date Field In Vb6 Programme
you mean make combo1 an array as well?
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by georgina
you mean make combo1 an array as well?
I mean click on the textbox that holds what you want to pass to frmMain. In its properties, the Index Number will be displayed. Example: Text1(1) - use whatever that number in this
VB Code:
frmMain.txtxtext2(x).Text
Where x = the number of its position on your control array.
-
Re: Date Field In Vb6 Programme
My txtxtext2 is an array field in frmMain.frm with values from 0 to 4 (total of 5 values). I now have 1 combo box (not in an array) in another form. If I set value to my text box like this:
frmMain.txtxtext2(2).Text = Combo1.Text
then I will get a value for 1 text box only
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by georgina
My txtxtext2 is an array field in frmMain.frm with values from 0 to 4 (total of 5 values). I now have 1 combo box (not in an array) in another form. If I set value to my text box like this:
frmMain.txtxtext2(2).Text = Combo1.Text
then I will get a value for 1 text box only
That is correct and up to this point, that is all you have indicated you needed.
What all do you need filled and from where would they get filled?
-
Re: Date Field In Vb6 Programme
I have 5 textboxes in array: frmMain.txtxtext2(i).Text, where i = 0 to 4 in frmMain.frm. They have the following source:
VB Code:
Private Sub txtxtext2_Click(Index As Integer)
frmoptiondate.Show
End Sub
Now, frmoptiondate.frm has a combo named Combo1 with the following code:
VB Code:
Private Sub Combo1_Click()
frmMain.txtxtext2(i).Text = Combo1.Text
End Sub
and at the same time there is the form load code in frmoptiondate.frm:
VB Code:
Private Sub Form_Load()
Dim i As Long
'enter todays date
Combo1.AddItem Format(Now, "long date")
'now add the remaining 365 dates for a
'rolling calendar year
For i = 1 To 365
Combo1.AddItem Format(Now + i, "long date")
Next
'set default to todays date
Combo1.ListIndex = 0
End Sub
So what happens is, no matter which of the frmMain.txtxtext2(i).Text, it is only the first one (i = 0) that gets the value (even if I click on the i = 1,2,3 or 4 text box).
Have I helped?
-
Re: Date Field In Vb6 Programme
On top of that, is there a way we can set a vacant start value ("") in this combo? I do not always need a date, I sometimes need to have no data at all but this
frmMain.txtxtext2(i).Text always takes the value of Combo1. What can we do about this?
-
Re: Date Field In Vb6 Programme
When you use this
VB Code:
Private Sub Combo1_Click()
frmMain.txtxtext2(i).Text = Combo1.Text
End Sub
Your program does not know what i equals so it doesn't know what textbox to put it in. When you declare a number variable, it defaults to 0, which is why your text is going into to Text1(0).Text. The question you have to answer is:
VB Code:
'do you want the text in
frmMain.txtxtext2(0).Text = Combo1.Text
'or do you want the text in
frmMain.txtxtext2(1).Text = Combo1.Text
'or do you want the text in
frmMain.txtxtext2(2).Text = Combo1.Text
'or do you want the text in
frmMain.txtxtext2(3).Text = Combo1.Text
'or do you want the text in
frmMain.txtxtext2(4).Text = Combo1.Text
Whichever is the case, replace i with the textboxs array number.
PS: I have added [vbcode][/vbcode] tags to your last post. As you can see, it makes reading what has been posted a lot easier. :)
-
Re: Date Field In Vb6 Programme
Thank you for everything. Yes, it is much easier to read now.
However, this doesn't work. I have a request with 5 columns (arrays) and I want to fill in 4 of them (4 hotels for example) without having to change the code in the Combo1 box.
If I select an i now then each time I want to set another value I will have to change the code = I am out of business (unless of course I haven't completely understood your comments).
There has to be a way that the frmoptiondate.frm realizes which textbox has been clicked or the whole thing will never work in a practical way.
If that is impossible, can I manually select the respective i (from 0 to 4) without changing the Combo1 code? Maybe by adding another form with a simple selection of i (perhaps by clicking on 5 checkboxes, each representing an i).
There has to be a way to do this.
-
Re: Date Field In Vb6 Programme
Ok, lets not think in terms of computers now. Lets think in terms of plain old people.
You have 5 textboxes on one form.
You have a combo box on another form. You select something from the combo box and that selection has to go into one of those 5 textboxes. As a person, how do you decide which textbox it goes into? What do those textboxs represent?
-
Re: Date Field In Vb6 Programme
That is not how it goes. You are right, I have 5 textboxes (an array of 5) and I click on one of them (let's say number 2) so it is in number 2 textboxthat I want this date inserted. I can send you an image of the whole thing if you think it will make it easier. Each request has everything in an array of 5, so I can give my clients a selection of 5 hotels ( and request from each one of them such a date, one at a time).
-
Re: Date Field In Vb6 Programme
Quote:
Originally Posted by georgina
That is not how it goes. You are right, I have 5 textboxes (an array of 5) and I click on one of them (let's say number 2) so it is in number 2 textboxthat I want this date inserted. I can send you an image of the whole thing if you think it will make it easier. Each request has everything in an array of 5, so I can give my clients a selection of 5 hotels ( and request from each one of them such a date, one at a time).
Ok. Then what relationship does that combo box have to these textboxes?
-
Re: Date Field In Vb6 Programme
I am not sure I know what you mean. As I mentioned before I am not a programmer, just a user.
I only want to click on the textboxes and get a date on it. If those textboxes were not in an array then it would be easy to do that.
By clicking on the textbox we simply open the form woth the combo. So, at the moment the combo cannot tell which textbox has been clicked. How can I force it to insert value in a specific textbox without altering the code all the time?
> Can I make the combo an array?
> Can I add another form that will tell the combo which textbox to change (giving a value to i through this new form)?
-
Re: Date Field In Vb6 Programme
Create a Public variable and set it in the GotFocus event of your textbox array.
VB Code:
Option Explicit
Public tbBox As TextBox
Private Sub Text1_GotFocus(Index As Integer)
Select Case Index
Case 0
Set tbBox = Text1(0)
Case 1
Set tbBox = Text1(1)
Case 2
Set tbBox = Text1(2)
Case 3
Set tbBox = Text1(3)
Case 4
Set tbBox = Text1(4)
End Select
End Sub
Private Sub Combo1_Click()
frmMain.tbBox.Text = Combo1.Text
End Sub
-
Re: Date Field In Vb6 Programme
As I cannot find something similar in the programme I cannot figure out what to do. I made an effort but got erros. Here is what I have now:
1. in my frmMain.frm the code for my txtxtext2 textbox:
Private Sub txtxtext2_Click(Index As Integer)
frmoptiondate.Show
End Sub
2. in my new frmoptiondate.frm for my Combo1:
Private Sub Combo1_Click()
date_today = Date
If Combo1.Text = Date Then
frmMain.txtxtext2(i).Text = ""
Else
frmMain.txtxtext2(i).Text = Combo1.Text
End If
End Sub
So I have no idea on what exactly to add and where to add it. There is no other GotFocus event in this programme to use as an example. On top of that the only public I have are in a Public.bas module and has various "Public Functions"
P.S. I managed to "force" the programme take dates in English but I had to change my regional settings.
-
Re: Date Field In Vb6 Programme
The GotFocus event is the one in your textboxes. Open a code window in your textbox. Drop down the combo on the right hand side of the code window. Scroll down to GotFocus
That is the event I'm talking about.