Results 1 to 15 of 15
  1. #1
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problems Opening Form From VB with Conditions (2000)

    Looking a bit of help.

    I have a command button which is suppose to open a report, but I get the following erro message: Runtime Error 13, Type mismatch.

    The code on the button is:

    DoCmd.OpenReport ReportName:="rptOfferForm", View:=acViewPreview, WhereCondition:="PID=" & Me!PID And "PropertyID=" & Me!PROPERTYID

    Amy ideas where I am going wrong?
    Best Regards,

    Luke

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

    Re: Problems Opening Form From VB with Conditions (2000)

    The And bit in the WhereCondition should be inside the quotes:

    ..., WhereCondition:="PID=" & Me!PID & " And PropertyID=" & Me!PROPERTYID

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Problems Opening Form From VB with Conditions (2000)

    old: DoCmd.OpenReport ReportName:="rptOfferForm", View:=acViewPreview, WhereCondition:="PID=" & Me!PID And "PropertyID=" & Me!PROPERTYID

    new: DoCmd.OpenReport ReportName:="rptOfferForm", View:=acViewPreview, WhereCondition:="PID=" & Me!PID & " PropertyID=" & Me!PROPERTYID


    Of course, this assumes both PID and PropertyID are numeric.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problems Opening Form From VB with Conditions (2000)

    Okay that works great, now I have a dilemna on the report which I know why it is doing it, but not sure how to correct it.

    I have three tables, tblProperty, tblOffers and tblPurchaser

    The tbloffers records the offers made by purchasers on properties. The same purchaser can make more than one offer on a property. When I scroll through a report that a certain purchaser has made more than one offer, the report is greater than one page but the next page has a duplicate of the subform at the top directly below. This only occurs on Purchasers that have offered more than once on a given property. Any ideas?
    Best Regards,

    Luke

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

    Re: Problems Opening Form From VB with Conditions (2000)

    Is tblOffers also part of the record source of the main report? It should only be in the record source of the subreport (I assume you meant subreport instead of subform).

  6. #6
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problems Opening Form From VB with Conditions (2000)

    Hans,

    i have checked this and the record source for the main report is nothing and the subreport is tbloffers and still the address appear twice on the same record for the report, any ideas?
    Best Regards,

    Luke

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

    Re: Problems Opening Form From VB with Conditions (2000)

    If the main report has an empty record source I don't know how it works. Could you attach a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions on how to reduce the size of a database for posting.

  8. #8
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problems Opening Form From VB with Conditions (2000)

    Here it is.

    Had to save it in 97 format.
    Best Regards,

    Luke

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

    Re: Problems Opening Form From VB with Conditions (2000)

    Thanks. Am I supposed to open a form first? If so, which one? (Your database contains lots of forms)

  10. #10
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problems Opening Form From VB with Conditions (2000)

    frmOfferFin

    Sorry forgot to mention it.
    Best Regards,

    Luke

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

    Re: Problems Opening Form From VB with Conditions (2000)

    If I try to open frmOfferFin I get four message boxes in a row complaining about missing (sub)forms. If I then click the command button Command78, I get prompted for values from the missing subforms.

  12. #12
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problems Opening Form From VB with Conditions (2000)

    For PID type 880

    For PropertyId type 349

    Then it should open the report and show you the issue I have?
    Best Regards,

    Luke

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

    Re: Problems Opening Form From VB with Conditions (2000)

    The subform/report is based on tblOffers. There are 2 records with the specified PropertyID and PID, so the subform/report is displayed twice. What else did you expect? If you want only one record, which one should it be?

  14. #14
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problems Opening Form From VB with Conditions (2000)

    What I would like is the property address to appear only once instead of re-occuring. Not sure on how to set this up now. The tblOffers records the offer amount and Purchasers ID and Property ID. So I want to display that property with that purchasers and list all the offer they have made on the property in the report so I can print it. If access could print a form with subforms I wouldn't need to do this.
    Best Regards,

    Luke

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

    Re: Problems Opening Form From VB with Conditions (2000)

    You'll have to design a real report instead of using a form as subreport. You can group data in a report, suppress duplicates etc.

Posting Permissions

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