Icon Visible if (1 Viewer)

Hmmm...I'll try it I guess. I have never used brackets in the table criteria so... :unsure:
Yup I guess it does work, not that I am going to use brackets there...:oops:
 
When I corrected the code to
Code:
=IIf([SwapCheck]>0,DCount("[IDDuty]","tblSwaps","[DutyDateNew] = #" & Format([DutyDate].[Value],"mm/dd/yyyy") & "#"),0)

the below comes up

1736163743303.png
 
Upload the DB, else we will be here forever.
Just need enough to see the issue, with instructions of what control/form etc.
 
Yup I guess it does work, not that I am going to use brackets there...:oops:
You can always use brackets and at times you have to use brackets. Imagine your table name was Table One. Just like field names spaces, reserved words, or special characters require brackets around a table name in Sql, expressions, and code if using bang notation
 
Last edited:
You can always use brackets and at times you have to use brackets. Imagine your table name was Table One. Just like field names spaces, reserved words, or special characters require brackets around a table name in Sql, expressions, and code if using bang notation
@Gasman
I have attached a a version of the DB, with some data for the example

From the frmMain you can open a current duty or create a new one

In simple the IcoSwap is to highlight if any new duty created is a consequence of a swapped duty, the table swaps contain information of any date the duties have been exchanged in advance of the actual duty.

Therefore when a new duty is created if the date entered matches one from the table swaps the icon should be visible.

The comparison is via the the DCount function within the txtbox SwapCheck in the frmDuties

I solved the error by placing a Now() withing the default value of the dutydate and it actually works, but I would like to avoid this solution and have removed it to re-create the error

On a new record the DutyDate has an after Update event to make the icon visible.

I am sure you will find many long winging errors in my DB and better ways of achieving this any feedback is welcome
 

Attachments

Before you upload anything, you need to test that it works? :(

I get this when trying to open form main? That field does not exist in that table?
1736246741830.png


Why do you have this code for the Open Event of frmMain?
Code:
Private Sub Form_Open(Cancel As Integer)
    DoCmd.Maximize
    stDocName = "frmMain"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

Edit:
IDDuty does not exist in tblSwaps either? :(
Code:
=DCount("[IDDuty]","[tblSwaps]","[DutyDateNew] = #" & Format([DutyDate].[Value],"mm/dd/yyyy") & "#")
1736248952585.png
 
Last edited:
You also need Option Explicit at the top of every module, form, report etc.

You need to add it manually for all those created so far and tick the Require Variable Declaration for future code.

1736254233227.png
 

Users who are viewing this thread

Back
Top Bottom