Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Thanked 0 Times in 0 Posts

    LinkCriteria in Openreport (Access 2000)

    LinkCriteria in OpenReport

    I have just asked the Forum how can i convert a string value into a number value and i received an excellent solution. (Thank you, Francois !!!)
    Now my new code works fine.Through a control called FindIt i am finding the CustomerID in the form Customers by typing its CompanyName and then the whole information about this Customer appears on my Form called Customers.I want now to go one step futher and open a report only for the Custoemr i have just typed its CustomerName.I cannot open the report, i receive the message syntax error missing operator
    the code i use is the following :

    Private Sub Findit_AfterUpdate()
    'Use the bookmark to move to a the selected customer
    'From "Microsoft Access 2000 Development Unleashed" (SAMS)
    'By: Forte, Howe, Ralston
    Dim rsclone As DAO.Recordset
    Dim recordID As Variant
    Dim IDValue As Long
    Set rsclone = Me.RecordsetClone
    IDValue = CStr(Me![Findit])
    recordID = "CustomerID = " & IDValue
    rsclone.FindFirst recordID
    bm = rsclone.Bookmark
    Me.Bookmark = bm

    'up to here the code is fine, the typed in Customer is populated on the form Customers.
    But then after pressing Enter to open the report, i receve the message syntax error.:
    Dim stLinkCriteria As String
    Dim stDocName As String
    stLinkCriteria = "CustomerID " & IDValue
    stDocName = "SalesSummary"
    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
    End Sub

    Can somebody help me where my mistake lies ?

  2. #2
    4 Star Lounger
    Join Date
    Jan 2001
    Altnau, Thurgau, Switzerland
    Thanked 0 Times in 0 Posts

    Re: LinkCriteria in Openreport (Access 2000)

    In the top few lines you define IDValue as long and then set it equal to CStr(...). Is this where one problem lies?
    Further down in the construction of the stLinkCriteria you have
    stLinkCriteria="CustomerID" & IDValue.
    It should be
    stLinkCriteria="CustomerID=" & IDValue

Posting Permissions

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