doCmd with two Condition

o2is4u

Registered User.
Local time
Today, 06:21
Joined
Sep 23, 2013
Messages
12
Maybe answered before but failed to see where :banghead: .
Appreciate to assist in setting two criteria where the two filed are text:
DoCmd.OpenReport "FixedDiscptnActvty", acViewPreview, , "StmntID = " & Me.StmntID & " And PaytoCurrency = " & Me.PayToCurrency
“StmntID =” & Me.StmntID…are working fine though the second criteria is always not matching and asking the user to enter the field.

Any clue J
 
Hello,

You mean "second field" ?
The next code as solution :
Code:
DoCmd.OpenReport  "FixedDiscptnActvty", acViewPreview, , "StmntID = " & Me.StmntID  & " And PaytoCurrency = '" & Me.PayToCurrency & "' And StmntID =” & Me.StmntID

Set
Me.PayToCurrency between quotes '
 
madefemere appears to have StmntID in the WHERE Clause twice. How about:

Code:
DoCmd.OpenReport "FixedDiscptnActvty", acViewPreview, ,"[ PaytoCurrency] = '" & Me. PaytoCurrency  & "' And [StmntID] = " & Me.StmntID

Linq ;0)>
 
Last edited:
Indeed missinglinq, a mistake that should not be there. I must be more careful the next.
 
madefemere appears to have StmntID in the WHERE Clause twice. How about:

Code:
DoCmd.OpenReport "FixedDiscptnActvty", acViewPreview, ,"[ PaytoCurrency] = '" & Me. PaytoCurrency  & "' And [StmntID] = " & Me.StmntID

Linq ;0)>


:) missinglinc .. Thanks it worked with a little twest as follows

DoCmd.OpenReport "FixedDiscptnActvty", acViewPreview, , " PaytoCurrency = '" & Me.PayToCurrency & "' And StmntID = " & Me.StmntID
 
Hello Again, I tried to apply same concept as follows:
/////
Private Sub Command50_Click()
On Error GoTo Err_Command50_Click
Dim stDocName As String
stDocName = "School Voucher"
DoCmd.OpenReport stDocName, acPreview, , " [Voucher No] = '" & Me.Voucher_No & "' And [Voucher Month] = " & Me.Voucher_Month
Exit_Command50_Click:
Exit Sub
Err_Command50_Click:
MsgBox Err.Description
Resume Exit_Command50_Click
End Sub
///
While the report opens for a view as needed, but missing entire data although by looking at report filter [Voucher No] = '333' And [Voucher Month] = 30/09/13
When I removed the
And [Voucher Month] = 30/09/13
The report works perfectly.

Any Clue ??
 
How is Voucher month stored in table? A number like 1, 2, 3.... 12 or Jan, Feb, Mar.. Dec or just a regular date 01/01/2012, 15/07/2013?

The code you have will look for the Voucher Number 333 which has the Date equal to 30/09/2013, not occurring in the month of September.
 
Dear pr2-eugin

The date is "Short Date like 31/10/13" where it is the end of the month for each voucher. And the objective is to match the Voucher No (Unique) Voucher Month (could be Repeated).

I have also tried on another date field still not wotking.

Await a reply

Thanks in advance
 
If it's a date field:

DoCmd.OpenReport stDocName, acPreview, , " [Voucher No] = '" & Me.Voucher_No & "' And [Voucher Month] = #" & Me.Voucher_Month & "#"
 
I managed to find a solution by changing the second condition with an auto number field from the table having Voucher No. Like this
Private Sub Command50_Click()
On Error GoTo Err_Command50_Click
Dim stDocName As String
stDocName = "Payment Voucher"
DoCmd.OpenReport stDocName, acPreview, , " [Voucher No] = '" & Me.Voucher_No & "' And [PVIDNo] = " & Me.PVIdNo

Exit_Command50_Click:
Exit Sub

Err_Command50_Click:
MsgBox Err.Description
Resume Exit_Command50_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom