PDA

View Full Version : [SOLVED:] requery problem



TonC
01-21-2016, 12:07 AM
Hello, I've got a requery problem. Access 2007, Windows8 :banghead:

A table named "tblWarenhuis"
In my subform (presented in datasheet view) in a headform, has several fields.

The recourdsorce form my subform is a query named "qryWarenhuis"

Table information:
The first field WH_Id is a nummeric field (No autonumbering)

The second field is just a date field named "Datum"
query Field: Datum, criteria is
Between [Forms]![frmWarenhuis]![txtStartDate] And [Forms]![frmWarenhuis]![txtEndDate]

The third field is a amount field named "Bedrag"

A field is a walking amount field named "Saldo" in qryWarenhuis
This field has the following expression in the qryWarenhuis.
Saldo: Format(DSum("Bedrag";"tblWarenhuis";"[WH_Id] <=" & [WH_Id] & "");" 0,00")

(description in QBE)
Field= Saldo: Format(DSum("Bedrag";"tblWarenhuis";"[WH_Id] <=" & [WH_Id] & "");" 0,00")
Table= Empty
Sort by= Empty
View= checkbox checked
Criteria= Empty

When I open the headform, It will give the correct information I want to see.

I would like to have a filterbutton for the date between start en enddate. When I click this button, the field "Saldo"must disappear (and it does), and when I click reset filterbutton, the field "Saldo" must appear again (does not).

At the moment I tried to do so. But when I click a reset filterbutton, the field "Saldo" gives me an error. In my datasheetview, in the field "Saldo" appears '#Naam? in all the rows of the datasheet. (Only "Saldo" field)

To get it to work again, I have to close the form, reopen it and Voila everything is business as usual.
Strange, is'n it? Is there a solution to requery the form or subform without closing the form?

I tried; of course with the reset filterbutton in my code,
Me. subfrmWarenhuis.Requery
or Me. subfrmWarenhuis.Form.FiterOn=False

Nothing helps.
What go's wrong? If you need additional information let me know.
Thanks in advance

jonh
01-21-2016, 05:18 AM
You didn't say what makes the field disappear now. That could be a clue.

anyway


Hide
Me.SUBFORM.Form.Controls("CONTROLNAME").ColumnHidden = True


Show
Me.SUBFORM.Form.Controls("CONTROLNAME").ColumnHidden = False

TonC
01-22-2016, 11:40 PM
Hello jonh,
Your clue was working fabulous! Simple but effective.
Many thanks.