Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2012
    Posts
    126

    Unanswered: Open form with two where conditions

    Im trying to open a form with two where conditions with the following VBA code


    Code:
    DoCmd.OpenForm "frmPickLogsForProduction", , , ("[EmployeeID]= " & Me![EmployeeID]) And ("[PickingDate]= " & Me![PickingDate])
    I keep getting error Type Mismatch. Any ideas?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    yes when you drop in and out of sting building you need to use the & to concatenate strings

    DoCmd.OpenForm "frmPickLogsForProduction", , , "[EmployeeID]= " & Me![EmployeeID]) & " And [PickingDate]= " & Me![PickingDate])

    in an ideal world picking date shoudl be in ISO or US foramt an delimted by #

    DoCmd.OpenForm "frmPickLogsForProduction", , , "[EmployeeID]= " & Me![EmployeeID]) & " And [PickingDate]= #" & format(Me![PickingDate],"yyyy/m/dd") & "#")

    ..when you see these sort of issues copy the bit of code that isn't working and exmaine it in the immediate window
    check the values are what you'd expect
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Aug 2012
    Posts
    126
    Quote Originally Posted by healdem View Post
    yes when you drop in and out of sting building you need to use the & to concatenate strings

    DoCmd.OpenForm "frmPickLogsForProduction", , , "[EmployeeID]= " & Me![EmployeeID]) & " And [PickingDate]= " & Me![PickingDate])

    in an ideal world picking date shoudl be in ISO or US foramt an delimted by #

    DoCmd.OpenForm "frmPickLogsForProduction", , , "[EmployeeID]= " & Me![EmployeeID]) & " And [PickingDate]= #" & format(Me![PickingDate],"yyyy/m/dd") & "#")

    ..when you see these sort of issues copy the bit of code that isn't working and exmaine it in the immediate window
    check the values are what you'd expect
    as always, thank you!

    Im having a hard time verifying the date in the immediate window. The employeeID part works great. I've tried "[pickdate] = #6/11/2014#" but it fails says type mismatch. I have the date field formatted as a medium date.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Pickdate or pickingdate?
    the format mask should be yyyy/mm/dd or mm/dd/yyyyy
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Aug 2012
    Posts
    126
    Quote Originally Posted by healdem View Post
    Pickdate or pickingdate?
    the format mask should be yyyy/mm/dd or mm/dd/yyyyy
    healdem i wanted to thank you for this. I finally got a chance to get back to this and its working perfectly. I really appreciate your assistance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •