PDA

View Full Version : Access isn't picking the right values



rushB
08-03-2020, 12:07 AM
Hello there,

I am making my first database and running into a small problem.
I created two tables which are linked via a 1:n relationship. In a form I took the main table and created a combo box with the values of the second table. Now I want that when the enduser picks a value from the combobox, Access calculates the next date. So for example when I chose "High Risk" Access will take the date ented in the box " Last Review Date" and put this value + 1 year in the field " Next Review Date"

for this I created a after update procedure

if Me.CRRB_ID_F = " High Risk"
Me.Basic_NRDate = Me.Basic_LRDate + 365
End if

if Me.CRRB_ID_F = " Medium Risk"
Me.Basic_NRDate = Me.Basic_LRDate + 720
End if

I hope someone could help me there
Stay safe

OBP
08-04-2020, 06:52 AM
Welcome to VBAX and Access.
You haven't said what results you actually get.
You also haven't said what the design of your tables is, or the Combo that you are using for selection.
The most common problem with combos is that it does not store the "selection that you see", it stores the ID or key field.
So when you use VBA like
if Me.CRRB_ID_F = " High Risk"
maybe you should be using
if Me.CRRB_ID_F = 1
or if Me.CRRB_ID_F = 2
depending on the key field.
Can you provide more data?

jjjulian
10-15-2020, 05:47 AM
Oi! Thanks for that, OBP!
I was already thinking about it as of something impossible.:crying: