Gibbo,

Originally Posted by
gibbo1715
I also assume id have to amend the above slightly to
[VBA]sSQL = "SELECT ID, FieldName1, FieldName2, FieldName3, FieldName4, _
FieldName5 FROM tbl_
Test WHERE FieldName3= '" & None & "';"
[/VBA]
Actually, I think Dennis overlooked or misunderstood what you were asking. What he wrote in the post to which you're responding in the above quotation is SQL and not VBA--despite his having had enclosed the SQL with VBA tags for the forum. To clear things up, the following is SQL:
SELECT ID, FieldName1, FieldName2, FieldName3, FieldName4, FieldName5
FROM tbl_Test WHERE FieldName3='None';
The following is an example of an SQL statement incorporated into VBA:
[VBA]
Sub DemoSQL()
Dim strSQL As String
strSQL = "SELECT ID, FieldName1, FieldName2, FieldName3, FieldName4, " _
& "FieldName5" & vbNewLine _
& "FROM tbl_Test WHERE FieldName3='" & Me.TextBox1.Value & "';"
Debug.Print strSQL
End Sub
[/VBA]
Results:
SELECT ID, FieldName1, FieldName2, FieldName3, FieldName4, FieldName5
FROM tbl_Test WHERE FieldName3='SampleData';
I suggest using helper functions to enclose criteria with quotation marks and pound signs (#) instead of writing them manually. It's not that they're difficult to write, but they are easy to overlook, so helper functions, no matter how simple, reduce errors.