Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2004, 02:05 AM
Registered User
 
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date combined from three combo boxes

I have an MS Access form, where a user enters the date by selecting it from three combo boxes for day, month and year. I need it to be converted to 11-Jan-2004 format and written to a table. Here is what I do:

Private Sub Form_AfterUpdate()
  Dim dtDateBooked As Date
  Dim strSQL As String

  dtDateBooked = DateSerial(Me.cboDayBook, Me.cboMonthBook, Me.cboYearBook)
  strSQL = "UPDATE tblBooking SET tblBooking.DateBooked= 'dtDateBooked'"
  CurrentDb.Execute strSQL, dbFailOnError
End Sub

And I get "Type Mismatch" error on DateSerial line. Any help would be greatly appreciated. Thanks!
 
Old January 6th, 2004, 09:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

DateSerial's arguments are integers. Try this:

dtDateBooked = DateSerial(Cint(Me.cboDayBook), Cint(Me.cboMonthBook), Cint(Me.cboYearBook))


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Boxes nbuckwheat Access 1 January 15th, 2006 09:26 AM
Combo boxes socoolbrewster Access 1 March 4th, 2004 09:28 AM
Combo Boxes tjs206 VB Databases Basics 2 December 10th, 2003 05:20 PM
Combo Boxes Louisa Beginning VB 6 2 September 10th, 2003 09:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.