Hi guys so I was browsing SO and one of the topics was "how to tell if a student coded this".. well I am a student working for a pretty big company as an intern. I recently coded a reporting tool for them in Access and have a question about a piece of code
'get the dates'
'check if both date fields are filled out'
If A_AfterDateTxt.Value <> "" And A_BeforeDateTxt.Value <> "" Then
'check if they are valid (ie, one date is not bigger then the other)'
If CDate(A_AfterDateTxt.Value) > CDate(A_BeforeDateTxt.Value) Then
MsgBox "You have selected invalid dates. Try again."
GetSQLForActiveRecords = False 'this is the function name
Exit Function 'exit the function'
Else
'this takes both fields and appends them to the sql statement'
strSql = strSql & " AND ([Submitted] >= #" & A_AfterDateTxt.Value & "# and [Submitted] <= #" & A_BeforeDateTxt.Value & "#)"
End If
Else
'one or both of them are blank, select the one thats entered
If (SF_isNothing(A_AfterDateTxt.Value) And Not SF_isNothing(A_BeforeDateTxt.Value)) Then
strSql = strSql & " AND ([Submitted] <= #" & A_BeforeDateTxt.Value & "#)"
ElseIf (SF_isNothing(A_BeforeDateTxt.Value) And Not SF_isNothing(A_AfterDateTxt.Value)) Then
strSql = strSql & " AND ([Submitted] >= #" & A_AfterDateTxt.Value & "#)"
End If
End If
note: SI_isnothing
is just a function that checks for a null/empty but since they data is from a textbox it will never be null right?
So there are two date textboxes (AfterDate, and BeforeDate). I build my SQL statement depending on what is filled out (ie, one is entered, the other empty)
So how can I modify this to make it more readable.