954,219 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

converting date from form to field in access

Hi
I have used three combo box in VB 6 form one for selecting date one for month and one for year. If the selection is say 12/07/2007 then I need it to be converted as 12/07/2007 under one field i.e date field of access database. So how can I do this.
For ref. combo1 is for date,combo2 is for month and combo3 is for year
and date is the field in database
table name is mm
database name is nn
Will any one help me by writing the necessary code.

(K.S.)

kehar
Junior Poster in Training
72 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

instead of using 3 combo boxes use DTPicker control and then find out the .Date .Month .year property of the control.

debasisdas
Posting Genius
6,870 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

Hi I have used three combo box in VB 6 form one for selecting date one for month and one for year. If the selection is say 12/07/2007 then I need it to be converted as 12/07/2007 under one field i.e date field of access database. So how can I do this. For ref. combo1 is for date,combo2 is for month and combo3 is for year and date is the field in database table name is mm database name is nn Will any one help me by writing the necessary code.

(K.S.)

You are using three combo box means three text fields.
Take three strings. Likewise strday = cmbday.text , strmonth = cmbmonth.text , stryear = cmbyear.text and While inserting in the database use this

(to_date('" & strday & "','dd-mm-yyyy') & to_date('" & strmonth & "','dd-mm-yyyy') & ('" & stryear & "','dd-mm-yyyy')

Try this in your inserting query and you have to try it.

yogesh_vaidya12
Newbie Poster
12 posts since Oct 2007
Reputation Points: 10
Solved Threads: 1
 

Try this.

Dim myDate as Date
Dim mth as String
Dim day as String
Dim yr as String
.
.
.
myDate = CDate(mth & "/" & day & "/" & yr)

hopalongcassidy
Junior Poster
148 posts since Oct 2007
Reputation Points: 53
Solved Threads: 13
 

I used the following code as a trial but it did not work.

Private Sub Command1_Click()
Dim a, b, c As String
Dim d As Date
d = CDate(text1.Text)
a = Combo1.Text
b = Combo2.Text
c = Combo3.Text
d=('" & a & "','dd-mm-yyyy') & to_date('" & b & "','dd-mm-yyyy') & ('" & c & "','dd-mm-yyyy')


End Sub

kehar
Junior Poster in Training
72 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

Hi
my intention is to make date month year selection as that of IRCTC (railway ticket booking site) There you have to select date month year in different combo box.
Hence any idea

kehar
Junior Poster in Training
72 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

I think that dbasisdas' suggestion is the simplest solution, however I've found datepickers to be pretty slow. Slow enough to be annoying.

Hoppy

hopalongcassidy
Junior Poster
148 posts since Oct 2007
Reputation Points: 53
Solved Threads: 13
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You