controlscontextmenums-access-2016unbound

A2019: how to get a context menu in a form for an unbound date control like for bound date controls


I'm not sure how it is possible to get the same contextmenu for an unbound form's control like for bound controls, both with a date value.

There are two unbound controls which get their control value via:

txtErsteSpende:

=Wenn([spSurrKey]>0;DomMin("[zaZahlDatum]";"[tblZahlungen]";"[zaSP_FKEY] = " & [Formulare]![frm110_Spender]![spSurrKey]);Null)

and

txtLetzteSpende:

=Wenn([spSurrKey]>0;DomMax("[zaZahlDatum]";"[tblZahlungen]";"[zaSP_FKEY] = " & [Formulare]![frm110_Spender]![spSurrKey]);Null)

Sorry for these are examples in german: "wenn" means "iif". It seems the bound control allows the context menu but not available for unbound controls.

Or is there a technique without writing vba-code to allow same context menu for both kind of controls?

Any suggestions appreciated thx

Contextmenu filter a date - bound control Contextmenu filter a date - unbound control


Solution

  • the goal was:

    After trying around with subforms which wasn't practable because the form is displayed in data sheet view I found this solution:

    qry110:

    SELECT tblSpender.spID, tblSpender.spNachname, tblSpender.spVorname, tblSpender.spOrt, tblSpender.spGebdat, DMin("[zaZahlungsdatum]","[tblZahlungen]","[zaSPFKEY] = " & Nz([tblSpender].[spID],0)) AS datErsteSpende, DMax("[zaZahlungsdatum]","[tblZahlungen]","[zaSPFKEY] = " & Nz([tblSpender].[spID],0)) AS datLetzteSpende
    FROM tblSpender;
    

    => works fine but shows #Error in the form's textbox when in table tblZahlungen there is no entry (no ForeignKey) for the PrimaryKey in tblSpender

    So I created a second query as recordsource for frm110 based on the first qry110 which checks the NULLvalue:

    qry111:

    SELECT qry110_Spender.spID, qry110_Spender.spNachname, qry110_Spender.spVorname, qry110_Spender.spOrt, qry110_Spender.spGebdat, IIf(Nz([datErsteSpende],0)>0,DateValue([datErsteSpende]),Null) AS datumErsteSpende, IIf(Nz([datLetzteSpende],0)>0,DateValue([datLetzteSpende]),Null) AS datumLetzteSpende
    FROM qry110_Spender;
    

    It works and now the form's recordset IS updatable. Maybe the form isn't very performant for big data but it's acceptable for my users

    thx for your hints

    contextmenu for date textboxes