Object doesn't support this property or method

Gordo

Registered User.
Local time
Today, 13:08
Joined
Feb 17, 2014
Messages
18
I thought I was smarter than this. Can anyone help me with this problem?

Here's my code:

If [Forms].[SalesForm].[DetailOption] Then
DoCmd.OpenQuery "SalesQuery", acViewNormal, acEdit
DoCmd.OpenReport "rptSalesDetailProduct_A", acViewReport, "", "", acNormal
Else
DoCmd.OpenQuery "SalesQuery", acViewNormal, acEdit
DoCmd.OpenQuery "SalesGroupbyProduct", acViewNormal, acEdit
DoCmd.OpenReport "rptSalesGroupbyProduct_A", acViewReport, "", "", acNormal
End If
 
...which line does it highlight?
 
Umm, what are you trying to say here?

Code:
If [Forms].[SalesForm].[DetailOption] Then
 
It looks like you are checking the Flag [Forms].[SalesForm].[DetailOption] to see if it is Yes/No or True/False.

You could use something like [Forms].[SalesForm].[DetailOption]=True instead.

If that is not the case and you are checking to see if a Field [Forms].[SalesForm].[DetailOption] has a value, then I believe the result will always be True as long as the Field [Forms].[SalesForm].[DetailOption] exists.

You could use something like Nz([Forms].[SalesForm].[DetailOption], "")<>"" instead.

Using more completely formatted condition statement would eliminate potential issues of this type.

-- Rookie
 
Actually it doesn't matter whether you put "=True" or not. The code already translates to this. That's why one can write If Not Something Then meaning If Something = False.

It's either DetailOption is not a field or control on the form (because the dot notation is used - which references properties or methods of an object) or the problem is in another code line.
 
Or sorry, Forms.FormName is wrong anyway. It should Forms!FormName. Again it has to do with the dot notation that references properties or methods of an object.
 
Sorry the problem is with the first line of code.

It doesn't matter if I put in [Forms].[SalesForm].[DetailOption]=True I still get the "Object doesn't support this property or method" error

I tried Forms!FormName and got a different error "Invalid use of Null"

Thanks, I appreciate everyone's input on this.
 
This didn't work because it's now referring not to the form object DetailOption but data in a table. The error I got was:

Records in table Order details would have no record on the one side.
 
Is DetailOption a True/False field? If not what is the Data Type?
 
Detail option is just an option button on the SalesForm. If I click it I want to run the detail report, If I don't click it I want to run the summary report.
 
Okay, so the Options are numeric, what are they 1 or 2 or something else?
 
when I put this in the immediate window I now get a result "-1"

?[Forms]![SalesForm]![Check12]

But I still get the error about "Records in table Order details would have no record on the one side."
 
Okay, hold the bus... You originally posted DetailOption and not I see Check12. What is the fields Data Type in the Table.
 
Sorry, I thought I'd try a new bus...I swapped out the option button for a checkbox, but still the same problem.
 
This does not refer to any data in a table, it's just an option, or a check box on a form.
 
@Gordo,

You can't change things around without telling us or we'll end up in Tibet with no way home. :confused:

Now, if you cnaged to an UNBOUND Check Box the first code should work because it should see True/False.
 
My apologies, I was in the process of telling you cause I was working on trying a bunch of things, but I got it working by just putting in "me.check12" instead of [Forms].[DetailForm].[Check12]...pretty simple when you know it.
 

Users who are viewing this thread

Back
Top Bottom