0

I dont fully understand this issue at all, it makes no sense to me for several reasons but ill liust the main ones
i have code elsewhere that works just fine and is identical in function and setup
i dont think the issue is a registry key issue, this i have checked
if the code works in those othe rplaces then why is it that it fails at the one?

here is the code

Option Compare Database

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    If NoticeLabel = "THIS IS YOUR ANNUAL NOTICE" Then
        AmountDueTotal1.Visible = False
        AmountDueTotal3.Visible = False
        AmountDueTotal6.Visible = True
        SubTotal1.Visible = False
        SubTotal3.Visible = False
        SubTotal6.Visible = True
        CountyTax1.Visible = False
        CountyTax3.Visible = False
        CountyTax6.Visible = True
        KyTax1.Visible = False
        KyTax3.Visible = False
        KyTax6.Visible = True
        TotalTax1.Visible = False
        TotalTax3.Visible = False
        TotalTax6.Visible = True
        LabelTax1.Visible = False
        LabelTax3.Visible = False
        LabelTax6.Visible = True

        LabelTax6.Value = Form!CountyTax6

'        Text312.Value = AmountDueTotal
        Label379.Caption = "6 Mo."
        Text385.Value = AmountDueTotal6
        Label389.Caption = "6 Mo."

'        Text422.Value = SubTotal6
        Label377.Caption = "6 Mo."
        Label387.Caption = "6 Mo."

        Text382.Value = KyTax6

    ElseIf NoticeLabel = "THIS IS YOUR 1 MONTH NOTICE" Then
        AmountDueTotal1.Visible = True
        AmountDueTotal3.Visible = False
        AmountDueTotal6.Visible = False
        SubTotal1.Visible = True
        SubTotal3.Visible = False
        SubTotal6.Visible = False
        CountyTax1.Visible = True
        CountyTax3.Visible = False
        CountyTax6.Visible = False
        KyTax1.Visible = True
        KyTax3.Visible = False
        KyTax6.Visible = False
        TotalTax1.Visible = True
        TotalTax3.Visible = False
        TotalTax6.Visible = False
        LabelTax1.Visible = True
        LabelTax3.Visible = False
        LabelTax6.Visible = False

        LabelTax1.Value = Form!CountyTax1

'        Text312.Value = AmountDueTotal
        Label379.Caption = "1 Mo."
        Text385.Value = AmountDueTotal1
        Label389.Caption = "1 Mo."

'        Text422.Value = SubTotal1
        Label377.Caption = "1 Mo."
        Label387.Caption = "1 Mo."

        Text382.Value = KyTax1

    ElseIf NoticeLabel = "THIS IS YOUR 3 MONTHS NOTICE" Then
        AmountDueTotal1.Visible = False
        AmountDueTotal3.Visible = True
        AmountDueTotal6.Visible = False
        Label379.Caption = "3 Mo."
        SubTotal1.Visible = False
        SubTotal3.Visible = True
        SubTotal6.Visible = False
        CountyTax1.Visible = False
        CountyTax3.Visible = True
        CountyTax6.Visible = False
        KyTax1.Visible = False
        KyTax3.Visible = True
        KyTax6.Visible = False
        TotalTax1.Visible = False
        TotalTax3.Visible = True
        TotalTax6.Visible = False
        LabelTax1.Visible = False
        LabelTax3.Visible = True
        LabelTax6.Visible = False

        LabelTax3.Value = Form!CountyTax3

'        Text312.Value = AmountDueTotal
        Label379.Caption = "3 Mo."
        Text385.Value = AmountDueTotal3
        Label389.Caption = "3 Mo."

'        Text422.Value = SubTotal3
        Label377.Caption = "3 Mo."
        Label387.Caption = "3 Mo."

        Text382.Value = KyTax3

    ElseIf NoticeLabel = "THIS IS YOUR 6 MONTHS NOTICE" Then
        AmountDueTotal1.Visible = False
        AmountDueTotal3.Visible = False
        AmountDueTotal6.Visible = True
        SubTotal1.Visible = False
        SubTotal3.Visible = False
        SubTotal6.Visible = True
        CountyTax1.Visible = False
        CountyTax3.Visible = False
        CountyTax6.Visible = True
        KyTax1.Visible = False
        KyTax3.Visible = False
        KyTax6.Visible = True
        TotalTax1.Visible = False
        TotalTax3.Visible = False
        TotalTax6.Visible = True
        LabelTax1.Visible = False
        LabelTax3.Visible = False
        LabelTax6.Visible = True

        LabelTax6.Value = Form!CountyTax6

'        Text312.Value = AmountDueTotal
        Label379.Caption = "6 Mo."
        Text385.Value = AmountDueTotal6
        Label389.Caption = "6 Mo."

'        Text422.Value = SubTotal6
        Label377.Caption = "6 Mo."
        Label387.Caption = "6 Mo."

        Text382.Value = KyTax6

    End If

End Sub

the line it keeps directing me to is LabelTax6.Value = Form!CountyTax6 at the bottom of the code, this same line was similarly used elsewhere and in the if statement those places work without fail but this one acts differently, im still new to this and unfortunatly this isnt my code, but i have been selected to fix it.
Any and all help is always appreciated, thank you for your time!

2
Contributors
5
Replies
18
Views
2 Years
Discussion Span
Last Post by rproffitt
1

I'm not an Access VBA expert but what if the field at the time was hidden. Maybe you can yield to the CPU with a DoEvents to let the form update prior to access to the item on the form. There's also a note about use of the ! versus the dot in the docs about Access. I'd try it with the dot for a test run.

0

I tried using doevents and nothing, then i tried messing around with the dot cause i like the dot much better than the ! anyway, no luck anywhere, but i did end up finding a different error whe ni changed that line LabelTax6.Value = Form!CountyTax6 to LabelTax6.Value = Report_FormReport.CountyTax6, when i did this it said i couldnt assign it as a varibale, to me thats progress lol

1

I am now wondering about the Form name. I read an article and this code snippet to get the current form.

https://msdn.microsoft.com/en-us/library/office/aa223199%28v=office.11%29.aspx?f=255&MSPPError=-2147217396

    Dim frmCurrentForm As Form
    Set frmCurrentForm = Screen.ActiveForm
    MsgBox "Current form is " & frmCurrentForm.Name

You know your code and form names, I don't but when I am tracing code I often have to drop snippets in like this to know for sure what form I'm on.

Edited by rproffitt: Spelling.

Votes + Comments
Excellent Advise, went straight for the issue!
1

DEAR rproffitt....

THANK YOU!!!

I initially felt th name and the way form was used in the code was weird. I tried deleting it from one place and that half fixed it so then you pointed out the form name and i tinkered with that for a while, then i realized that if i just delete the form name line from each of the if statements then BLAME! all is right with rain!

0

No need to reply. Thanks for hanging in there as I only have helped a few of our Access folk at the office and never used it in my apps. But there is some commonality to VB(1 thru .NET!) so I don't mind digging into it. Folk that can work with that are nice to have around.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.