Hello,
I'm continuing to have a bear of a time trying to accommodate null values in my insert statement. In particular (a simplified version):
sql1 = "INSERT INTO tblStudent ( [DOB] ) VALUES ( #" & rs1![DOB] & "#) ;"
This statement works fine when there is a date in DOB. But when it is null, I get a run-time error 3075: Syntax error in date in query expression ##.
Ok, so I tried an IIf statement based on another forum I saw, as follows:
sql1 = "INSERT INTO tblStudent ( [DOB] ) VALUES ( " & IIf(IsNull(" & rs1![DOB] & "), Null, "#" & rs1![DOB] & "#") & ") ;"
The above gives me the same syntax error. I've also tried it with quotes around "Null", still no joy. I simply want to accommodate possible null values in my date fields. The actual query is much longer, has several of these date fields (including others) and gets quite messy with these IIf statements. Any suggestions would be very much appreciated. Thanks!
I'm continuing to have a bear of a time trying to accommodate null values in my insert statement. In particular (a simplified version):
sql1 = "INSERT INTO tblStudent ( [DOB] ) VALUES ( #" & rs1![DOB] & "#) ;"
This statement works fine when there is a date in DOB. But when it is null, I get a run-time error 3075: Syntax error in date in query expression ##.
Ok, so I tried an IIf statement based on another forum I saw, as follows:
sql1 = "INSERT INTO tblStudent ( [DOB] ) VALUES ( " & IIf(IsNull(" & rs1![DOB] & "), Null, "#" & rs1![DOB] & "#") & ") ;"
The above gives me the same syntax error. I've also tried it with quotes around "Null", still no joy. I simply want to accommodate possible null values in my date fields. The actual query is much longer, has several of these date fields (including others) and gets quite messy with these IIf statements. Any suggestions would be very much appreciated. Thanks!