converting date from form to field in access

Thread Solved

Join Date: Sep 2007
Posts: 70
Reputation: kehar is an unknown quantity at this point 
Solved Threads: 0
kehar kehar is offline Offline
Junior Poster in Training

converting date from form to field in access

 
0
  #1
Oct 6th, 2007
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.)
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,093
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 126
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: converting date from form to field in access

 
0
  #2
Oct 6th, 2007
instead of using 3 combo boxes use DTPicker control and then find out the .Date .Month .year property of the control.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 11
Reputation: yogesh_vaidya12 is an unknown quantity at this point 
Solved Threads: 1
yogesh_vaidya12 yogesh_vaidya12 is offline Offline
Newbie Poster

Re: converting date from form to field in access

 
0
  #3
Oct 6th, 2007
Originally Posted by kehar View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 147
Reputation: hopalongcassidy is an unknown quantity at this point 
Solved Threads: 13
hopalongcassidy's Avatar
hopalongcassidy hopalongcassidy is offline Offline
Junior Poster

Re: converting date from form to field in access

 
0
  #4
Oct 7th, 2007
Try this.

Dim myDate as Date
Dim mth as String
Dim day as String
Dim yr as String
.
.
.
myDate = CDate(mth & "/" & day & "/" & yr)
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 70
Reputation: kehar is an unknown quantity at this point 
Solved Threads: 0
kehar kehar is offline Offline
Junior Poster in Training

Re: converting date from form to field in access

 
0
  #5
Oct 8th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 70
Reputation: kehar is an unknown quantity at this point 
Solved Threads: 0
kehar kehar is offline Offline
Junior Poster in Training

Re: converting date from form to field in access

 
0
  #6
Oct 8th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 147
Reputation: hopalongcassidy is an unknown quantity at this point 
Solved Threads: 13
hopalongcassidy's Avatar
hopalongcassidy hopalongcassidy is offline Offline
Junior Poster

Re: converting date from form to field in access

 
0
  #7
Oct 8th, 2007
I think that dbasisdas' suggestion is the simplest solution, however I've found datepickers to be pretty slow. Slow enough to be annoying.

Hoppy
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC