Open Form Button With Filter

maytime

Registered User.
Local time
Today, 09:53
Joined
Apr 1, 2008
Messages
29
I have a form that prompts the user to select criteria so they can run their own custom queries. On that form is a button that allows them to launch a data entry form on just the records that they queried for. I'm trying to write 'stLinkCriteria' statement so that the form to be opened will be filtered correctly but I'm running into problems. Basically I want to write a ' = Like OF* or like GB*' statement so that all records with 'OF' or 'GB' in the control field are returned. Here is my code, with the problem area bolded...any ideas?:

Code:
Private Sub ENCL_DS_QB_Click()
On Error GoTo Err_ENCL_DS_Form_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
        
    stDocName = "Enclosures TRM_QB"
    [B]stLinkCriteria = "[Unique Tag] Like 'GB*' or Like 'OF*'"[/B]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
   
Exit_ENCL_DS_Form_Click:
    Exit Sub

Err_ENCL_DS_Form_Click:
    MsgBox Err.Description
    Resume Exit_ENCL_DS_Form_Click
End Sub
 
Last edited:
I figured it out. I had to have my stLinkCriteria statement as:

Code:
stLinkCriteria = "[Unique Tag] Like 'GB*'" & "Or [Unique Tag] LIke 'OF*'"
 
try this (or a mod of it) I think your missing a quote..
'text104 is unbound search box
If Me.Text104 = "" Then

MsgBox "I'm sorry, I have nothing to search for", vbOKOnly
Me.Text104.SetFocus

Else
Me.Filter = "[order_number] Like " & "'*" & Me![Text104] & "*'"

Me.FilterOn = True
Me.No_rec_label.Visible = (Me.Recordset.RecordCount = 0)

End If
Me.Text104 = ""
 

Users who are viewing this thread

Back
Top Bottom