how to save data from textbox to a table field (1 Viewer)

TipsyWolf

Member
Local time
Today, 20:43
Joined
Mar 20, 2024
Messages
112
hey guys !

i have a form and in this form a have a textbox where it gets date by Expr (calculated date) and i need to save this data (date) to one of my field of table.

i tried to play with VBA ,
Code:
Private Sub Text63_BeforeUpdate(Cancel As Integer)
dueDate = Me.Text63
End Sub
but it doesnt work for me as Im low skill in coding \ access
do u have any advice for me please ?

upd:
a form has record source with the same table i want to save data from textbox
 

GPGeorge

Grover Park George
Local time
Today, 10:43
Joined
Nov 25, 2004
Messages
1,878
First, it's generally understood that storing calculated values should be done only in specific circumstances and is usually not a good idea. If the underlying values used in the calculation will not change, there is not reason to store the resulting calculation redundantly in a separate field. Therefore, I'd question even doing this.

That said, the standard bound table would not require VBA to store any values bound to any control on the form in any case.

And finally, we probably don't want to let the generic, Access supplied default name "Text63" live on. It's a good idea to change it to reflect what it displays.
 

TipsyWolf

Member
Local time
Today, 20:43
Joined
Mar 20, 2024
Messages
112
First, it's generally understood that storing calculated values should be done only in specific circumstances and is usually not a good idea. If the underlying values used in the calculation will not change, there is not reason to store the resulting calculation redundantly in a separate field. Therefore, I'd question even doing this.

That said, the standard bound table would not require VBA to store any values bound to any control on the form in any case.

And finally, we probably don't want to let the generic, Access supplied default name "Text63" live on. It's a good idea to change it to reflect what it displays.
the reson i want to store it just based of my lack of knowing of access and it drives me to avoid complex calc and functions
but if u could help me with my issue, i would be so much glad for it !
i have a parent and child table (one to many)
1712148929373.png

i needed to calc min. date of specific record and thanks to AWF members especially @mike60smart that helped me a lot with Dcount.
but now i have a new challege for me.
I have a dashboard (like main menu) with calculated statisic. how do i calculate numbers of Tmain records where min. date are less, than date(). i mean overdue.

IF this min date would be in the same table - i would just do
=(DCount("riskcode";"Tmain";"riskcode >= 20 AND riskcode <=25 and duedate<date()"))

but i made a qeiry that gets this min date and i tried somehow to make it work and im having issues with it. i just can't

Code:
=(DCount("riskcode";"Tmain";"riskcode >= 20")) And (DCount("MinOfDueDate";"qmindate";"MinOfDueDate<Date()"))
. #error.
 

TipsyWolf

Member
Local time
Today, 20:43
Joined
Mar 20, 2024
Messages
112
horray !
i solved it myself , finally !

i reedit my query
1712153489598.png


and i just put
Code:
=(DCount("MinOfDueDate";"Qddall";"MinOfDueDate<date() and riskcode between 20 and 25"))

and for every RiskType just changed RiskCode 1 to 7 , 8 to 13 ... etc. and now my statistic works fine

1712153596917.png


and another things a have to do is create an double click event when it opens a materlist (countinious form) with pre-set filters so it opens only records that fit condition and # of records according to these calculated numbers.

already made with one simple ALL (no conditions) with macrobuilder.
1712153814079.png


but im not sure how to put conditions there from query, cause instead of saving data to a main table, i have my records in query... how do i set condition this way ? any suggestins ?
 
Last edited:

TipsyWolf

Member
Local time
Today, 20:43
Joined
Mar 20, 2024
Messages
112
as i was expecte it, it doesnt work this way. thats why i wanted to save calculated date to a main table, cause
1712154902617.png


1712154922166.png


and i quite understand why it asks me to input parameter, cause it doesnt know which one record it should get from Qddall query
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:43
Joined
Feb 19, 2002
Messages
43,308
and for every RiskType just changed RiskCode 1 to 7 , 8 to 13 ... etc. and now my statistic works fine
You can do this without code and therefore without requiring future maintenance. Please reread my earlier suggestion.
 

Users who are viewing this thread

Top Bottom