Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    opening Query through Code (XP/2K)

    I have the following query which runs perfectly well as a normal query when the form is open:

    PARAMETERS [Forms]![frmBalanceKupah]![dtDateBalanceStart] DateTime, [Forms]![frmBalanceKupah]![dtDateBalanceEnd] DateTime;
    SELECT Sum(tblExtendPayment.curAmountShekel) AS SumOfcurAmountShekel, tblExtendPayment.txtbank
    FROM (tblTotalPurchase INNER JOIN tblExtendPayment ON tblTotalPurchase.IDTotalPurchase = tblExtendPayment.IDTotalPurchase) INNER JOIN tblPurchase ON tblTotalPurchase.IDTotalPurchase = tblPurchase.idTotalPurchase
    WHERE (((tblPurchase.dtdate) Between [Forms]![frmBalanceKupah]![dtDateBalanceStart] And [Forms]![frmBalanceKupah]![dtDateBalanceEnd]))
    GROUP BY tblExtendPayment.txtbank
    HAVING (((tblExtendPayment.txtbank)="

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: opening Query through Code (XP/2K)

    ADO doesn't know anything about Access forms. You have to specify the parameters in code:

    Dim rst As ADODB.Recordset
    Dim cmd As New ADODB.Command
    Dim prm As ADODB.Parameter
    With cmd
    .ActiveConnection = CurrentProject.Connection
    .CommandText = "qerCashForKupah"
    .CommandType = adCmdStoredProc
    Set prm = .CreateParameter("[Forms]![frmBalanceKupah]![dtDateBalanceStart]", _
    adDate, adParamInput, , [Forms]![frmBalanceKupah]![dtDateBalanceStart])
    .Parameters.Append prm
    Set prm = .CreateParameter("[Forms]![frmBalanceKupah]![dtDateBalanceEnd]", _
    adDate, adParamInput, , [Forms]![frmBalanceKupah]![dtDateBalanceEnd])
    .Parameters.Append prm
    Set rst = cmd.Execute
    End With

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: opening Query through Code (XP/2K)

    I always read about this, now maybe i will figure it out

Posting Permissions

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