1,105,546 Community Members

Ms Access Combine day,month and time into single field

Member Avatar
Krs13
Newbie Poster
17 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,

I have an access database where in i have 3 separate fields for day, month and year which are comboboxes. I have an separate field where i need to combine these 3 fields into that single field(dd/mm/yyyy). can somebody help me on this please.

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

Try the following -

Dim xYear As Integer, xMonth As Integer, xDay As Integer, xResult as String

xYear = rs!year ''Change rs to your record selector name...
xMonth = rs!month ''Also change the field names year, month, day to your field names...
xDay = rs!day

xResult = xDay & "/" & xMonth & "/" & xYear

MsgBox xResult
Member Avatar
Krs13
Newbie Poster
17 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Can you please guide me as to where this code should appear. Something like in on update field or on change... thanks

Member Avatar
rishif2
Posting Whiz in Training
284 posts since Dec 2012
Reputation Points: 57 [?]
Q&As Helped to Solve: 58 [?]
Skill Endorsements: 4 [?]
 
0
 

try the following:-

Dim dt1 As String
dt1 = Combo1.Text & "/" & Combo2.Text & "/" & Combo3.Text
con.Provider = "Microsoft.Jet.OLEDB.4.0"
con.Open App.Path & "\db.mdb"
con.Execute  "INSERT INTO tbl(dtfield) VALUES('" & dt1 & "')", adCmdText
con.Close
Set con = Nothing

if still not answered , then please make your thread more clear else mark this post as solved . . .

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article