Results 1 to 38 of 38

Thread: Date Field In Vb6 Programme

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Date Field In Vb6 Programme

    How many consequtive days should be in your dropdown?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    Re: Date Field In Vb6 Programme

    All year's dates. This is a programme for my travel agency that works all year round.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  5. #5
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043

    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
    oh1mie/Vic


  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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)

  7. #7
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043

    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)
    oh1mie/Vic


  8. #8

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Date Field In Vb6 Programme

    Welcome to the forums by the way.
    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:
    1. Private Sub Form_Load()
    2. Dim i As Long
    3. 'enter todays date
    4. Combo1.AddItem Format(Now, "long date")
    5. 'now add the remaining 365 dates for a
    6. 'rolling calendar year
    7. For i = 1 To 365
    8.     Combo1.AddItem Format(Now + i, "long date")
    9. Next
    10. 'set default to todays date
    11. Combo1.ListIndex = 0
    12. End Sub

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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.

  12. #12
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043

    Re: Date Field In Vb6 Programme

    Now function is picking everytime date and time from computers clock
    oh1mie/Vic


  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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?

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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.

  16. #16
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  17. #17
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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.

  19. #19
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  20. #20

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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?

  21. #21
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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:
    1. Private Sub Combo1_Click()
    2. Text1.Text = Combo1.Text

  22. #22

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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)?

  23. #23
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  24. #24

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    Re: Date Field In Vb6 Programme

    you mean make combo1 an array as well?

  25. #25
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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:
    1. frmMain.txtxtext2(x).Text
    Where x = the number of its position on your control array.

  26. #26

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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

  27. #27
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  28. #28

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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:
    1. Private Sub txtxtext2_Click(Index As Integer)
    2. frmoptiondate.Show
    3. End Sub
    Now, frmoptiondate.frm has a combo named Combo1 with the following code:
    VB Code:
    1. Private Sub Combo1_Click()
    2.       frmMain.txtxtext2(i).Text = Combo1.Text
    3. End Sub
    and at the same time there is the form load code in frmoptiondate.frm:
    VB Code:
    1. Private Sub Form_Load()
    2. Dim i As Long
    3. 'enter todays date
    4. Combo1.AddItem Format(Now, "long date")
    5. 'now add the remaining 365 dates for a
    6. 'rolling calendar year
    7. For i = 1 To 365
    8.     Combo1.AddItem Format(Now + i, "long date")
    9. Next
    10. 'set default to todays date
    11. Combo1.ListIndex = 0
    12. 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?
    Last edited by Hack; Mar 6th, 2006 at 12:58 PM. Reason: Added [vbcode] [/vbcode] tags and for more clarity.

  29. #29

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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?

  30. #30
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Date Field In Vb6 Programme

    When you use this
    VB Code:
    1. Private Sub Combo1_Click()
    2.       frmMain.txtxtext2(i).Text = Combo1.Text
    3. 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:
    1. 'do you want the text in
    2.       frmMain.txtxtext2(0).Text = Combo1.Text
    3.       'or do you want the text in
    4.       frmMain.txtxtext2(1).Text = Combo1.Text
    5.      'or do you want the text in
    6.       frmMain.txtxtext2(2).Text = Combo1.Text
    7.      'or do you want the text in
    8.       frmMain.txtxtext2(3).Text = Combo1.Text
    9.      'or do you want the text in
    10.       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.

  31. #31

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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.

  32. #32
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  33. #33

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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).

  34. #34
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  35. #35

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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)?

  36. #36
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Date Field In Vb6 Programme

    Create a Public variable and set it in the GotFocus event of your textbox array.
    VB Code:
    1. Option Explicit
    2.  
    3. Public tbBox As TextBox
    4.  
    5. Private Sub Text1_GotFocus(Index As Integer)
    6. Select Case Index
    7.     Case 0
    8.        Set tbBox = Text1(0)
    9.     Case 1
    10.        Set tbBox = Text1(1)
    11.     Case 2
    12.        Set tbBox = Text1(2)
    13.     Case 3
    14.        Set tbBox = Text1(3)
    15.     Case 4
    16.        Set tbBox = Text1(4)
    17. End Select
    18. End Sub
    19.  
    20. Private Sub Combo1_Click()
    21.       frmMain.tbBox.Text = Combo1.Text
    22. End Sub

  37. #37

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    23

    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.

  38. #38
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width