Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Question Unanswered: trying to use recordsource properly..

    I am unfamiliar with using recordsource, and have some trouble with error messages I do not understand. It is only about the basics, but still...

    I have tried both DAO and ADO, but cannot get it to work. The libraris are referenced/enabled.

    Lots of the trials are now commented out , but you can see what I am struggling with...

    Last message was about "too few arguments. Expected 2".
    It stops on the line where I am using the select statement, the select statement itself should be one, and dbOpenDynaset should be number two, I have copied the example right out of a manual and just added my select statement, but it does not work...

    Here is my code:

    Public Function fNewAvg(client_number As Long, RIC As Long, share_price_after_comm As Long, NofShares As Long) As Long
    On Error GoTo Err_fNewAvg

    Dim rstHoldings As Recordset
    ' Dim rstH As ADODB.Recordset
    ' Dim DBInfo As DAO.Database
    Dim DBTrading As DAO.Database
    Dim rstH2 As DAO.Recordset

    ' Set rstH = New ADODB.Recordset

    ' rstH.LockType = adLockReadOnly
    ' rstH.CursorType = adOpenStatic
    ' rstH.Open Source:="(SELECT tbl_holdings.CID, tbl_holdings.SID, tbl_holdings.prev_avg, tbl_holdings.prev_bal, tbl_holdings.new_avg, tbl_holdings.new_bal FROM tbl_Holdings WHERE (((tbl_holdings.CID)=client_number) AND ((tbl_holdings.SID)=RIC)))"

    Set DBTrading = CurrentDb()
    ' Set DBInfo = CurrentDb()
    'Set rstH2 = DBInfo.OpenRecordset("tblClients", dbOpenDynaset)
    Set rstH2 = DBTrading.OpenRecordset("(SELECT tbl_holdings.CID, tbl_holdings.SID, tbl_holdings.prev_avg, tbl_holdings.prev_bal, tbl_holdings.new_avg, tbl_holdings.new_bal FROM tbl_Holdings WHERE (((tbl_holdings.CID)=client_number) AND ((tbl_holdings.SID)=RIC)))", dbOpenDynaset)
    ' Set rstH2 = DBInfo.OpenRecordset("(SELECT tbl_holdings.CID, tbl_holdings.SID, tbl_holdings.prev_avg, tbl_holdings.prev_bal, tbl_holdings.new_avg, tbl_holdings.new_bal FROM tbl_Holdings WHERE (((tbl_holdings.CID)=client_number) AND ((tbl_holdings.SID)=RIC)))", dbOpenSnapshot)

    ....

    Any tips are highly appreciated.
    Pity there is no fast-chat function on this board to quickly sort out minor issues like such basic things (but still have the chat posted in the thread...)

    kedaniel

  2. #2
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    Building your sql string incorrectly...

    change to -
    WHERE (((tbl_holdings.CID)=" & Client_number & ") AND ((tbl_holdings.SID)=" & RIC & ")))", dbOpenDynaset)


    number=" & lngValue & " .......
    text=' & strValue & "' ....

Posting Permissions

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