mtwildtrout
Technical User
I want to open a form showing certain records based on information entered by the user in a data entry form. There is a command button on a data entry subform which contains the open form code. I need to only present records based on two information fields - WorkDate & EmployeeID. Part of the code I'm using is as follows:
Dim stLinkCroteria As String
stLinkCrieria = "[EmployeeID]=" & "'" & Me!EmployeeID] & "'"
DoCmd.OpenForm stdocName, acFormDS, , stLinkCriteria
This code works but when I add the second criteria with an "AND" I get a Type Mismatch error. The addtional statement I'm using is -
AND "[WorkDate]=" & "#" & Me![WorkDate] & "#"
This statement & the one above were genrated by the wizard, so I assume the coding is correct. Maybe a bad assumption?
When I use the above selection criteria individually, it works. However, when I join them together with an AND, I get a Type Mismatch error. Both date fields are formatted as short dates.
Are you limited to only one select criteria when using DoCmd.OpenForm? Is my coding of the criteria wrong? Is there another way to accomplish what I'm trying to do?
Dim stLinkCroteria As String
stLinkCrieria = "[EmployeeID]=" & "'" & Me!EmployeeID] & "'"
DoCmd.OpenForm stdocName, acFormDS, , stLinkCriteria
This code works but when I add the second criteria with an "AND" I get a Type Mismatch error. The addtional statement I'm using is -
AND "[WorkDate]=" & "#" & Me![WorkDate] & "#"
This statement & the one above were genrated by the wizard, so I assume the coding is correct. Maybe a bad assumption?
When I use the above selection criteria individually, it works. However, when I join them together with an AND, I get a Type Mismatch error. Both date fields are formatted as short dates.
Are you limited to only one select criteria when using DoCmd.OpenForm? Is my coding of the criteria wrong? Is there another way to accomplish what I'm trying to do?