0

I have a Numeric field in a table. the field named "Pr330USD" in a form, control source of a textbox named "PrEvFees" has been linked to that field.

I have also two buttons named:

OpenReportFRR

OpenFRRDraft

for opening two different Reports.

I wrote below codes aforementioned buttons:

Private Sub PrEvFees_BeforeUpdate(Cancel As Integer)
    If Me.PrEvFees.Value >= 300 Then
        OpenReportFRR.Enabled = True
        OpenFRRDraft.Enabled = False
    Else
        OpenReportFRR.Enabled = False
        OpenFRRDraft.Enabled = True
    End If

    DoCmd.Save
    DoCmd.RefreshRecord

End Sub

Problems are: After insert an amount (less than 300 USD or above) the buttons doesn't change their situations and also Refresh command doesn't work (I have on the line included "DoCmd.RefreshRecord" a yellow alert).

any idea is thanks full.

3
  • 3
    Protip: try to edit your title so that someone having a similar problem would type it in a Google search box and find your question (and its answers!). As it stands, this title applies to virtually every single VBA question ever asked on this site. Commented Aug 17, 2016 at 19:36
  • 2
    The BeforeUpdate event is called before an update is made to an existing record that is loaded in the form. However you said after insert an amount is it a new record or an already existing one? Commented Aug 17, 2016 at 19:45
  • Move the code to the AfterUpdate event. Commented Aug 18, 2016 at 7:29

1 Answer 1

1

Ok guys, thank you... especially Mat's Mug and litelite :)

Finally, the codes with removing a line (last line about "Refresh" order) works correctly. the final codes are below:

Private Sub PrEvFees_BeforeUpdate(Cancel As Integer)

If Me.PrEvFees.Value >= 300 Then

    OpenReportFRR.Enabled = True
    OpenFRRDraft.Enabled = False

Else

    OpenReportFRR.Enabled = False
    OpenFRRDraft.Enabled = True

End If

    DoCmd.Save

End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.