944,050 Members | Top Members by Rank

Ad:
Oct 6th, 2007
0

converting date from form to field in access

Expand 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.)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
kehar is offline Offline
72 posts
since Sep 2007
Oct 6th, 2007
0

Re: converting date from form to field in access

instead of using 3 combo boxes use DTPicker control and then find out the .Date .Month .year property of the control.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Oct 6th, 2007
0

Re: converting date from form to field in access

Click to Expand / Collapse  Quote originally posted by kehar ...
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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
yogesh_vaidya12 is offline Offline
11 posts
since Oct 2007
Oct 7th, 2007
0

Re: converting date from form to field in access

Try this.

Dim myDate as Date
Dim mth as String
Dim day as String
Dim yr as String
.
.
.
myDate = CDate(mth & "/" & day & "/" & yr)
Reputation Points: 53
Solved Threads: 13
Junior Poster
hopalongcassidy is offline Offline
148 posts
since Oct 2007
Oct 8th, 2007
0

Re: converting date from form to field in access

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
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
kehar is offline Offline
72 posts
since Sep 2007
Oct 8th, 2007
0

Re: converting date from form to field in access

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
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
kehar is offline Offline
72 posts
since Sep 2007
Oct 8th, 2007
0

Re: converting date from form to field in access

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

Hoppy
Reputation Points: 53
Solved Threads: 13
Junior Poster
hopalongcassidy is offline Offline
148 posts
since Oct 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: find the error pls...
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Making a Quiz on VB using ADO and access 2003





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC