Before Change SetField Editable (1 Viewer)

Mackbear

Registered User.
Local time
Today, 10:27
Joined
Apr 2, 2019
Messages
168
Hello everyone, reaching out again for help :eek::eek::eek:

I have a BeforeChange Data Macro SetField to set a default value on another field. Basically I just want the field to have a default but would need it to be editable, it should be able to be changed as needed. However I found that once I set the field, it cannot be changed. Is there a way to make it editable?

Thank you!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:27
Joined
Oct 29, 2018
Messages
21,456
Hi. No need for a macro. Have you tried simply using the Default Value property? Otherwise, you could adjust your macro to only set the field if it's empty.
 

Mackbear

Registered User.
Local time
Today, 10:27
Joined
Apr 2, 2019
Messages
168
Hi. No need for a macro. Have you tried simply using the Default Value property? Otherwise, you could adjust your macro to only set the field if it's empty.

Hello, yes I tried it, but I would like it to get the value from another field on the same table, does not work on the default value property...
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:27
Joined
Oct 29, 2018
Messages
21,456
Hello, yes I tried it, but I would like it to get the value from another field on the same table, does not work on the default value property...
Are you duplicating the other field's value or using it as a reference for a calculation?
 

Mackbear

Registered User.
Local time
Today, 10:27
Joined
Apr 2, 2019
Messages
168
Are you duplicating the other field's value or using it as a reference for a calculation?

It is somewhat duplicating, I just need to retain the original value of the other field and create a field which would carry the same value but there may be times that the value may not be the same anymore so users need to change it... I hope my explanation is clear?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:27
Joined
Oct 29, 2018
Messages
21,456
It is somewhat duplicating, I just need to retain the original value of the other field and create a field which would carry the same value but there may be times that the value may not be the same anymore so users need to change it... I hope my explanation is clear?

Hi, not sure I completely follow. If field1 was originally a "yes", for example, you want field2 to say yes as well. Then, you want the user to be able to change field2, so you could have field1=yes and field2=no. What happens if field1 gets changed to a maybe? Does field2 need to automatically change as well?
 

Mackbear

Registered User.
Local time
Today, 10:27
Joined
Apr 2, 2019
Messages
168
Hi, not sure I completely follow. If field1 was originally a "yes", for example, you want field2 to say yes as well. Then, you want the user to be able to change field2, so you could have field1=yes and field2=no. What happens if field1 gets changed to a maybe? Does field2 need to automatically change as well?

Field 1 should never be changed, Field 2 is just a copy of field 1 and may change at some time... I don't want to do an update query for this as much as possible, I would like to have the field automatically populated as soon as records are added...and in the future users can change field 2 if necessary... I hope this is ok?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:27
Joined
Oct 29, 2018
Messages
21,456
Field 1 should never be changed, Field 2 is just a copy of field 1 and may change at some time... I don't want to do an update query for this as much as possible, I would like to have the field automatically populated as soon as records are added...

Ah, I see. If field1 can never change, then we could assume an empty field2 should be equal to field1, right? Essentially, Nz(field2, field1). You should still be able to fix your macro, but if it was me, I would simply leave field2 empty at the start. Users are then free to add and change its value anytime.
 

Mackbear

Registered User.
Local time
Today, 10:27
Joined
Apr 2, 2019
Messages
168
Ah, I see. If field1 can never change, then we could assume an empty field2 should be equal to field1, right? Essentially, Nz(field2, field1). You should still be able to fix your macro, but if it was me, I would simply leave field2 empty at the start. Users are then free to add and change its value anytime.

Do I put Nz(field2, field1) to the Setfield of the Macro?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:27
Joined
Oct 29, 2018
Messages
21,456
Do I put Nz(field2, field1) to the Setfield of the Macro?

No. I would use it wherever I need to use field2. For example, in a query for a form or report.
 

Mackbear

Registered User.
Local time
Today, 10:27
Joined
Apr 2, 2019
Messages
168
No. I would use it wherever I need to use field2. For example, in a query for a form or report.

Oh I see... Because I would need to have the Field 2 to always have values though... So query is the only option
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:27
Joined
Oct 29, 2018
Messages
21,456
Oh I see... Because I would need to have the Field 2 to always have values though... So query is the only option
No, it's not the only option, but it's the most appropriate one, I believe. You should still be able to fix your data macro, if you want to continue with that route. If it was me, I would be happy with the query, since you're only supposed to store the necessary data in the table anyway, so you'll be following the rules, so to speak.
 

Users who are viewing this thread

Top Bottom