WavyGravy
asked on
Displaying Days Remaining in Access Form
I am currently developing a system that allows an individual to record information on a client (first name, last name, etc.). This information is stored in a table named client.
A client can make visits to the facility. When they do, their visit is logged in the visits table, which records the date they came, and what area they occupied.
Anyway, the clients information is entered into the form, while the visit is logged within a subform. How can I create a label on the form that will count the number of visits a client has made, and then subtract that number from 30?
Any and all help is greatly appreciated. Thanks!
A client can make visits to the facility. When they do, their visit is logged in the visits table, which records the date they came, and what area they occupied.
Anyway, the clients information is entered into the form, while the visit is logged within a subform. How can I create a label on the form that will count the number of visits a client has made, and then subtract that number from 30?
Any and all help is greatly appreciated. Thanks!
No code is needed.
Use this expression that updates automatically:
=[subChild].[Form].[Record setClone]. [RecordCou nt]
where subChild is not the name of the subform but the name of the subform control on the parent form holding the subform.
/gustav
Use this expression that updates automatically:
=[subChild].[Form].[Record
where subChild is not the name of the subform but the name of the subform control on the parent form holding the subform.
/gustav
ASKER
capricorn1, do you know of a way to have the textbox update without having to click it, or really perform any action? I'm using Access 2010 if it matters.
cactus_data, the name of my subform control is "visits" for the visits table, right? The expression syntax is confusing to me, I apologize.
cactus_data, the name of my subform control is "visits" for the visits table, right? The expression syntax is confusing to me, I apologize.
place the codes in the current event of the form, like this
private sub form_current()
me.text1=30-dcount("*","vi sitstable" ,"custID=" & me.custID)
end sub
private sub form_current()
me.text1=30-dcount("*","vi
end sub
ASKER
Got it. Any way to make it update after inputting data in the visits subform?
in the afterupdate of the subform, try this
me.parent.recalc
me.parent.recalc
ASKER
Am I missing something here? Doesn't want to update after adding a record.
Private Sub visits_subform_AfterUpdate()
Me.Parent.Recalc
End Sub
where is the Textbox located? and what is the name of the textbox that you used?
ASKER
The textbox is located in the main form named "clients"
"visits subform" renders within the clients form.
Right now the textbox is named "Text284"
"visits subform" renders within the clients form.
Right now the textbox is named "Text284"
test this
Private Sub visits_subform_AfterUpdate ()
' Me.Parent.Recalc
me.parent.text284=30-dcoun t("*","vis itstable", "custID=" & me.custID)
End Sub
Private Sub visits_subform_AfterUpdate
' Me.Parent.Recalc
me.parent.text284=30-dcoun
End Sub
Nothing confusing about:
=[Visit].[Form].[Recordset Clone].[Re cordCount]
and it updates automagically!
/gustav
=[Visit].[Form].[Recordset
and it updates automagically!
/gustav
ASKER
No luck with the following:
Private Sub visits_subform_AfterUpdate()
' Me.Parent.Recalc
Me.Parent.Text284 = 30 - DCount("*", "visits", "clientID=" & Me.clientID)
End Sub
place this line of code in the Control Source of Text284
= 30 - DCount("*", "visits", "clientID=" & Me.clientID)
= 30 - DCount("*", "visits", "clientID=" & Me.clientID)
place this line of code in the Control Source of Text284
= 30 - DCount("*", "visits", "clientID=" & Forms!clients!clientID)
ASKER
Runtime error.
Says that you can't assign a value to this object.
Says that you can't assign a value to this object.
can you upload your db?
ASKER
Same error for the second line of code you suggested as well.
Should I remove the form_current and afterupdate sections?
Should I remove the form_current and afterupdate sections?
sorry, remove those codes in the the form_current and afterupdate sections?
ASKER
I'm cleaning out the tables and getting ready to upload a version that you can look at.
ASKER
Here's a stripped version of the DB. I took all of the code out as well.
WorkInProgress.accdb
WorkInProgress.accdb
btw, did you set the child/master link fields for the subform?
ASKER
Would that be the same thing as primary and foreign keys?
<Would that be the same thing as primary and foreign keys?> yes
in the design view of the form, select the subform control, hit F4, select the Data tab and you will see those two properties, click on the (...) and select what was suggested by the wizard.
ASKER
They're both using clientID.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Works like a charm! Thanks!
ASKER
Superb help!
better using an unbound textbox that you will format to look like a label
me.text1=30-dcount("*","vi