Hi
I have just finished making a search engine with access 2000
and will filter the records fine. But to allow a message box to tell the user no records were found i had to add a recordset etc, since adding the dim rst as record set, set rst = db.openrecordset etc, it said type mismatch 13.
So i then added the DAO 3.6 and made it priority.
ok this then didnt bring up a error message but completely ignored all my query strings and just showed all my records. heres the code, can someone help me correct it pls.
Private Sub Command63_Click()
DoCmd.OpenForm "amending"
With Forms!amending
Dim db As Database
Dim rst As Recordset
Select Case Dates
Case 1
strsql = "Select * From [OLSquery] Where " _
& " transactiondate like '*'"
Case 2
strsql = "select * from [olsquery] Where " _
& " transactiondate = #" & Date & " #"
Case 3
strsql = "select * from [olsquery] where" _
& " transactiondate between #" & Me!From & " # and #" & Me!To & " #"
End Select
Select Case Order_Number
Case 1
strsql = "select * from [olsquery] Where " _
& " PoNo like '*'"
Case 2
strsql = "select * from [olsquery] where " _
& " PoNo = '" & Me!Order & " '"
End Select
Select Case Product_Code
Case 1
strsql = "select * from [olsquery] where " _
& " ProductCode like '*'"
Case 2
strsql = "select * from [olsquery] where " _
& " productcode = '" & Me!Product & " '"
End Select
Select Case TransType
Case 1
strsql = "select * from [olsquery] where " _
& " transtype like '*'"
Case 2
strsql = "select * from [olsquery] where " _
& " transtype = '" & Me!trans & " '"
End Select
Set db = CurrentDb()
Set rst = db.OpenRecordset(strsql, dbOpenDynaset)
If rst.RecordCount < 1 Then
MsgBox "No records found", vbOKOnly, "Try Again"
Else
Forms![amending].Form.RecordSource = strsql
DoCmd.Close acForm, "olsamend"
End If
End With
End Sub
I know there is a way of consolidating it, but i want it working first b4 i tart it up.
I have just finished making a search engine with access 2000
and will filter the records fine. But to allow a message box to tell the user no records were found i had to add a recordset etc, since adding the dim rst as record set, set rst = db.openrecordset etc, it said type mismatch 13.
So i then added the DAO 3.6 and made it priority.
ok this then didnt bring up a error message but completely ignored all my query strings and just showed all my records. heres the code, can someone help me correct it pls.
Private Sub Command63_Click()
DoCmd.OpenForm "amending"
With Forms!amending
Dim db As Database
Dim rst As Recordset
Select Case Dates
Case 1
strsql = "Select * From [OLSquery] Where " _
& " transactiondate like '*'"
Case 2
strsql = "select * from [olsquery] Where " _
& " transactiondate = #" & Date & " #"
Case 3
strsql = "select * from [olsquery] where" _
& " transactiondate between #" & Me!From & " # and #" & Me!To & " #"
End Select
Select Case Order_Number
Case 1
strsql = "select * from [olsquery] Where " _
& " PoNo like '*'"
Case 2
strsql = "select * from [olsquery] where " _
& " PoNo = '" & Me!Order & " '"
End Select
Select Case Product_Code
Case 1
strsql = "select * from [olsquery] where " _
& " ProductCode like '*'"
Case 2
strsql = "select * from [olsquery] where " _
& " productcode = '" & Me!Product & " '"
End Select
Select Case TransType
Case 1
strsql = "select * from [olsquery] where " _
& " transtype like '*'"
Case 2
strsql = "select * from [olsquery] where " _
& " transtype = '" & Me!trans & " '"
End Select
Set db = CurrentDb()
Set rst = db.OpenRecordset(strsql, dbOpenDynaset)
If rst.RecordCount < 1 Then
MsgBox "No records found", vbOKOnly, "Try Again"
Else
Forms![amending].Form.RecordSource = strsql
DoCmd.Close acForm, "olsamend"
End If
End With
End Sub
I know there is a way of consolidating it, but i want it working first b4 i tart it up.