Results 1 to 3 of 3
  1. #1
    hazeleyre23 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    34

    How to define the parameter with a pass through query

    Hi,

    I have a pass through query which is fine If I hard code the date, however I want it to be able to run off this query based on a date field the form...is this possible?

    The below function add's two working days to the date.
    SELECT [DATABASE].[dbo].fn_CalcDate('2016-12-30', 2) AS TwoDays

    I have tried to put [Forms]![Main]![CBODATE] where the date is above however I keep getting an error saying:

    Conversion failed when converting date and/or time from character string (#241).



    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Convert the date in the vb code. Don't do it in the SQL.

  3. #3
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,035
    You're calling a SQL function and the SQL server cannot see your form, so I think the best way to do this is to create a VBA procedure that fills in the correct values and executes the query.
    Another option would be to recreate the function fn_calcdate in Access VBA, and call the VBA function from your form.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 03-24-2016, 06:12 PM
  2. Replies: 7
    Last Post: 03-11-2015, 12:48 PM
  3. Pass parameter to a VBA Module
    By testing2Three in forum Modules
    Replies: 4
    Last Post: 11-13-2014, 02:33 PM
  4. Replies: 13
    Last Post: 05-14-2013, 06:01 PM
  5. Pass a Parameter From a form to a Query
    By DDillesha in forum Forms
    Replies: 1
    Last Post: 10-28-2009, 12:49 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums