J
Joshua Barnette
I am trying to LOOP through every field on my UNBOUND form. I am doing
this to convert any ".." to "*" and then to concatenate the populated
fields into a search string for the filter. My code is below, along
with a list of fields found on the form. Any help is greatly
appreciated.
PS...I am open to changing the way this is setup.
Code:
Dim ACMD_Search_STR As String
Dim ACMD_Conv_Fiels As String
Dim ACMD_fld As Field
For Each ACMD_fld In Me.Form
ACMD_Conv_Field = ""
ACMD_Conv_Field = Replace(ACMD_fld, "..", "*")
ACMD_fld = ACMD_Conv_Field
ACMD_Conv_Field = ""
Next ACMD_fld
ACMD_Search_STR = ""
For Each ACMD_fld In Me.Form
If IsNull(ACMD_fld) Then
Else
If ACMD_Search_STR = "" Then
ACMD_Search_STR = """ & ACMD_fld.Name & " Like """ &
ACMD_fld.value & """
Else
ACMD_Search_STR = """ & ACMD_Search_STR & " And " &
ACMD_fld.Name & " Like """ & ACMD_fld.value & """
End If
End If
Next ACMD_fld
' This line is so I could view the output before running the DoCMD
below.
Me.Notes = ACMD_Search_STR
' DoCmd.OpenForm "ACMD Data", acNormal, , ACMD_Search_STR
' List of Fields on Form
' Me.Items_Needed_For_This_File
' Me.Doc
' Me.Weight
' Me.[File#]
' Me.Name
' Me.[OPart#]
' Me.[EPart#]
' Me.Voltage
' Me.RPM
' Me.HP
' Me.AMPS
' Me.MFG_By
' Me.[MFG_Part#]
' Me.[Model#]
' Me.Size
' Me.Type
' Me.Stud_Kit
' Me.[Fan#]
' Me.Three_Phase_Stator
' Me.Oil_Seal
' Me.DE_Bearing
' Me.Back_End_Bearing
' Me.Drive_Endbell
' Me.Back_Endbell
' Me.Other_Numbers_Unknown
' Me.Same_Motor_As
' Me.Notes
' Me.General_Overhaul
' Me.Exchange
' Me.Wholesale
' Me.[Computer_ID#]
this to convert any ".." to "*" and then to concatenate the populated
fields into a search string for the filter. My code is below, along
with a list of fields found on the form. Any help is greatly
appreciated.
PS...I am open to changing the way this is setup.
Code:
Dim ACMD_Search_STR As String
Dim ACMD_Conv_Fiels As String
Dim ACMD_fld As Field
For Each ACMD_fld In Me.Form
ACMD_Conv_Field = ""
ACMD_Conv_Field = Replace(ACMD_fld, "..", "*")
ACMD_fld = ACMD_Conv_Field
ACMD_Conv_Field = ""
Next ACMD_fld
ACMD_Search_STR = ""
For Each ACMD_fld In Me.Form
If IsNull(ACMD_fld) Then
Else
If ACMD_Search_STR = "" Then
ACMD_Search_STR = """ & ACMD_fld.Name & " Like """ &
ACMD_fld.value & """
Else
ACMD_Search_STR = """ & ACMD_Search_STR & " And " &
ACMD_fld.Name & " Like """ & ACMD_fld.value & """
End If
End If
Next ACMD_fld
' This line is so I could view the output before running the DoCMD
below.
Me.Notes = ACMD_Search_STR
' DoCmd.OpenForm "ACMD Data", acNormal, , ACMD_Search_STR
' List of Fields on Form
' Me.Items_Needed_For_This_File
' Me.Doc
' Me.Weight
' Me.[File#]
' Me.Name
' Me.[OPart#]
' Me.[EPart#]
' Me.Voltage
' Me.RPM
' Me.HP
' Me.AMPS
' Me.MFG_By
' Me.[MFG_Part#]
' Me.[Model#]
' Me.Size
' Me.Type
' Me.Stud_Kit
' Me.[Fan#]
' Me.Three_Phase_Stator
' Me.Oil_Seal
' Me.DE_Bearing
' Me.Back_End_Bearing
' Me.Drive_Endbell
' Me.Back_Endbell
' Me.Other_Numbers_Unknown
' Me.Same_Motor_As
' Me.Notes
' Me.General_Overhaul
' Me.Exchange
' Me.Wholesale
' Me.[Computer_ID#]