Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing current Record (2002/SP2)

    The following code is in one database I have that opens a report based on the current record that is on display in a form. The code works. My problem is that I want to use the code in another database but the two ID fields do not exist in the new database. The matching fields are LNFN. Just substituting LNFN for ID doesn't work. I suspect the problem is that ID is a number and LNFN is text. How do I write the code to work with LNFN.

    Thanks

    Paul


    Dim intAnswer As Integer
    Dim rst As Recordset
    intAnswer = MsgBox(("Print " & FN & " " & LN & "'s record?"), vbYesNo + vbQuestion, _
    "Please Respond")
    Select Case intAnswer
    Case vbYes
    DoCmd.OpenReport "rptIndividualStudent", acViewNormal, , "id= " & Me.ID
    Set rst = Forms!frmMaster.RecordsetClone
    rst.FindFirst "ID=" & Me.ID
    Forms!frmMaster.Bookmark = rst.Bookmark
    MsgBox ("Record Printed.")
    End Select

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

    Re: Printing current Record (2002/SP2)

    Text values must be enclosed in quotes. Try "LNFN= " & Chr(34) & Me.LNFN & Chr(34)
    Chr(34) is the code for the double quote character ".

  3. #3
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing current Record (2002/SP2)

    Hans- didn't work.

    I get a compile error - method or data member not found when it gets to the word findfirst.

    Any other ideas?

    Thanks

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

    Re: Printing current Record (2002/SP2)

    1. Have you set a reference to the Microsoft DAO 3.6 Object Library? (In Tools | References...)

    2. To avoid confusion with the ADO Recordset object, declare rst explicitly as a DAO Recordset:

    Dim rst As DAO.Recordset

  5. #5
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing current Record (2002/SP2)

    I made your suggestions and now I don't get a compile error but a box pops up asking me to type in the LNFN that I originally selected to open the form. The matching of LNFN and LNFN is not happening. Is there another way to do this?

    Thanks

    Paul

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

    Re: Printing current Record (2002/SP2)

    This is hardly something we can help with from a distance - you'll have to investigate yourself why LNFN is not recognized. Make sure that there are no typos in your code, and that a valid value of LNFN is available when you try to open the report.

    If you still can't find the cause of the error, consider posting a stripped down version of your database:
    <UL><LI>Make a copy of the database and work with that.
    <LI>Remove all database objects (tables, forms, etc.) that are not relevant to the problem.
    <LI>In the remaining table(s), remove most records - leave only the minimum number necessary to demonstrate the problem.
    <LI>Remove or modify data of a confidential nature.
    <LI>Do a compact and repair (Tools/Database Utilities).
    <LI>Make a zip file containing the database; it should be below 100KB.
    <LI>Attach the zip file to a reply.[/list]This will enable Loungers to investigate the problem.

Posting Permissions

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