Gasman
Enthusiastic Amateur
- Local time
- Today, 11:49
- Joined
- Sep 21, 2011
- Messages
- 17,075
As most of you know, I advocate to use Google or another search engine to see if you can find a solution before asking for help.
It does not work a lot of the times I know, but I will persevere.
Anyway on another forum, someone was asking for properties of a combo box and the following link was provided.
To save you going there, the pertinent code I am talking about is below.
And this code is from Microsoft?
If they cannot get it right........
It does not work a lot of the times I know, but I will persevere.

Anyway on another forum, someone was asking for properties of a combo box and the following link was provided.

To save you going there, the pertinent code I am talking about is below.
And this code is from Microsoft?

Code:
Private Sub cmdSearch_Click()
Dim db As Database
Dim qd As QueryDef
Dim vWhere As Variant
Set db = CurrentDb()
On Error Resume Next
db.QueryDefs.Delete "Query1"
On Error GoTo 0
vWhere = Null
vWhere = vWhere & " AND [PymtTypeID]=" & Me.cboPaymentTypes
vWhere = vWhere & " AND [RefundTypeID]=" & Me.cboRefundType
vWhere = vWhere & " AND [RefundCDMID]=" & Me.cboRefundCDM
vWhere = vWhere & " AND [RefundOptionID]=" & Me.cboRefundOption
vWhere = vWhere & " AND [RefundCodeID]=" & Me.cboRefundCode
If Nz(vWhere, "") = "" Then
MsgBox "There are no search criteria selected." & vbCrLf & vbCrLf & _
"Search Cancelled.", vbInformation, "Search Canceled."
Else
Set qd = db.CreateQueryDef("Query1", "SELECT * FROM tblRefundData WHERE " & _
Mid(vWhere, 6))
db.Close
Set db = Nothing
DoCmd.OpenQuery "Query1", acViewNormal, acReadOnly
End If
End Sub