Re: SQL HANGS
- From: "Dirk Goldgar" <dg@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 1 Sep 2006 13:00:26 -0400
"DS" <bootybox@xxxxxxxxxxxxx> wrote in message
news:6AoJg.60$6z5.58@xxxxxxxxxxxx
This works unless the TxtCCExpDate field is left blank. If I leaveDeposits(DepositID,DepositDate,DepositAmount,Customer,Employee,Manager,M
that field blank which it can sometimes be then I get a Syntax Error
in Date Query Expression. Any way of fixing this so that I can leave
the TxtCCExpDate field empty if I need to?
Thanks
DS
Me.TxtDepositID = Nz(DMax("[DepositID]", "Deposits"), 0) + 1
CurrentDb.Execute "INSERT Into
emo,DepositType,CardNumber,ExpDate)
" & _
"VALUES('" & Forms!AddDeposit!TxtDepositID & "'," & _
"#" & Forms!AddDeposit!TxtDepositDate & "#," & _
"'" & Forms!AddDeposit!TxtDepositAmount & "'," & _
"'" & Forms!AddDeposit!TxtCussID & "'," & _
"'" & Forms!AddDeposit!TxtEmployee & "'," & _
"'" & Forms!AddDeposit!TxtManager & "'," & _
"'" & Forms!AddDeposit!TxtMemo & "'," & _
"'" & Forms!AddDeposit!TxtDepositType & "'," & _
"#" & Forms!AddDeposit!TxtCCExpDate & "#," & _
"'" & Forms!AddDeposit!TxtCCNumber & "')"
Please don't use the word "hangs" in describing your problem unless
whatever is happening causes the program to stop responding. It's
misleading. Just getting an error is not "hanging", nor is it
"crashing", as people sometimes write.
As for your problem: you need to check whether the control is Null, and
substitute the keyword "Null" in the SQL string in place of the date
literal you would otherwise build. For example,
[ ... ]
IIf(IsNull(Forms!AddDeposit!TxtCCExpDate), _
"Null,", _
"#" & Forms!AddDeposit!TxtCCExpDate & "#,") & _
[ ... ]
It would be better, though, to format date literals into mm/dd/yyyy
format, to avoid any ambiguity:
[ ... ]
IIf(IsNull(Forms!AddDeposit!TxtCCExpDate), _
"Null", _
Format(Forms!AddDeposit!TxtCCExpDate, "\#mm/dd/yyyy\#")) & _
"," & _
[ ... ]
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
.
- Prev by Date: Re: Update text box based on data in combo box
- Next by Date: Re: Many-to-many forms
- Previous by thread: update Form and its subForm via two textboxes
- Next by thread: Re: Many-to-many forms
- Index(es):
Relevant Pages
|