Hi,
I want to carry out a certain process on all the controls on a form so obviously I created a Function for it. I need to do slightly different things though depending on the controls datatype.
Here's partial code:
Private Function Filter_Builder(strSQL As String, field_name As Control, form1 As Form) As String
Dim fieldType As String
fieldType = field_name.DataType
Select Case fieldType
Case "Text"
If Len(strSQL) = 1 Then
strSQL = strSQL & "([" & field_name.Name & "] = '" & Nz(field_name, ""
& "')"
Else
strSQL = strSQL & " AND " & "([" & field_name.Name & "] = '" & Nz(field_name, ""
& "')"
End If
Case "Memo"
Case "Number"
Case "Currency"
Case "Yes / No"
Case "Date / Time"
End Select
Filter_Builder = strSQL
End Function
Unfortunately when the control is a combo box, I get an error saying that the object doesn't support this property, ie. datatype.
Does anyone know how I can get round this?
Cheers,
Pete
I want to carry out a certain process on all the controls on a form so obviously I created a Function for it. I need to do slightly different things though depending on the controls datatype.
Here's partial code:
Private Function Filter_Builder(strSQL As String, field_name As Control, form1 As Form) As String
Dim fieldType As String
fieldType = field_name.DataType
Select Case fieldType
Case "Text"
If Len(strSQL) = 1 Then
strSQL = strSQL & "([" & field_name.Name & "] = '" & Nz(field_name, ""
Else
strSQL = strSQL & " AND " & "([" & field_name.Name & "] = '" & Nz(field_name, ""
End If
Case "Memo"
Case "Number"
Case "Currency"
Case "Yes / No"
Case "Date / Time"
End Select
Filter_Builder = strSQL
End Function
Unfortunately when the control is a combo box, I get an error saying that the object doesn't support this property, ie. datatype.
Does anyone know how I can get round this?
Cheers,
Pete