Append Query and Nulls

padlocked17

Registered User.
Local time
Today, 12:52
Joined
Aug 29, 2007
Messages
275
So, I've been doing doing reading on Append Queries and Nulls. I have the following SQL statement

Code:
INSERT INTO tblTestResults ( EnrollmentID, TestType, Result, CompletedDate, BoldFace )
SELECT tblEnrollment.EnrollmentID, tblTests.TestsID, [Forms]![frmHome]![subfrmTesting]![txtResult] AS Result, [Forms]![frmHome]![subfrmTesting]![txtCompletedDate] AS CompletedDate, tblOptionsBF.OptionsBFID
FROM tblEnrollment, tblOptionsBF, tblTests
WHERE (((tblEnrollment.EnrollmentID)=[Forms]![frmHome]![EnrollmentID]) AND ((tblTests.TestsID)=[Forms]![frmHome]![subfrmTesting]![cboSelectTest]) AND ((tblOptionsBF.OptionsBFID)=IIf(IsNull([Forms]![frmHome]![subfrmTesting]![cboSelectBF]),0,[Forms]![frmHome]![subfrmTesting]![cboSelectBF])));

and I can't for the life of me figure out.

Code:
IIf(IsNull([Forms]![frmHome]![subfrmTesting]![cboSelectBF]),"",[Forms]![frmHome]![subfrmTesting]![cboSelectBF

Basically what I'm trying to say is that if the cboSelectBf is Null, then leave it null for the the append query or at least leave it blank. If it isn't, use the value that cboSelectBF has according to the combo box selection.

Any help would be greatly appreciated.
 
You must put the IIF statement in de select part of the query, not in the where part.

HTH:D
 
I could use a little more guidance. Don't think I've ever used a deselect portion of an SQL statement.
 
Sorry, i am dutch

You must put the IIF statement in the select part of the query, not in the where part.

Sorry, for the Typo. Hope this makes sense.
 

Users who are viewing this thread

Back
Top Bottom