Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input box driving me nuts!!!

Status
Not open for further replies.

mike1971

MIS
Feb 12, 2003
13
GB
Hi there,

I'm trying to use a pop up input box to set the reporting date for a number of queries, this is my code but instead of updating with the date I get what appears a calculation of dd/mm/yyyy...

ps some of you might recognise this code as it came from this site...thanks.

Mike


Sub selectdate()

Dim Message, Title, Default As String
Dim COBDate, MyValue As Date

On Error GoTo Errhdl

Message = "Enter Reporting COB Date (dd/mm/yyyy)"
Title = "InputBox Demo"
Default = IIf(Now() <> vbSunday Or vbSaturday, Date - 1, Date - 3)
COBDate = Format(InputBox(Message, Title, Default), &quot;dd/mm/yyyy&quot;)


DoCmd.SetWarnings True
DoCmd.RunSQL &quot;Update [TCOBDateOld] SET [RptDate] = &quot; & [COBDate] & &quot; Where [RecordID] = 'Y'&quot;
DoCmd.SetWarnings True
Exit Sub

Errhdl:
MsgBox &quot;Date Update Failed!&quot;
Exit Sub

End Sub


 
[yinyang]

try
Code:
Sub selectdate()

Dim Message, Title, Default As String
Dim COBDate, MyValue As Date

On Error GoTo Errhdl

Message = &quot;Enter Reporting COB Date (dd/mm/yyyy)&quot;
Title = &quot;InputBox Demo&quot;
Default = IIf(Now() <> vbSunday Or vbSaturday, Date - 1, Date - 3)
COBDate = cdate(InputBox(Message, Title, Default))


DoCmd.SetWarnings True
DoCmd.RunSQL &quot;Update [TCOBDateOld] SET [RptDate] = #&quot; & COBDate & &quot;# Where [RecordID] = 'Y'&quot;
DoCmd.SetWarnings True
    Exit Sub

Errhdl:
    MsgBox &quot;Date Update Failed!&quot;
    Exit Sub

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top