If blank field

Jakeman

Registered User.
Local time
Today, 15:12
Joined
Feb 14, 2010
Messages
34
As user is filling out form, if they “check” the checkbox field1, they are to enter the cost in field2. Sometimes they leave field2 blank. How can I default to a value of 55.00 if field2 is null?
Thanks from me again.
 
As user is filling out form, if they “check” the checkbox field1, they are to enter the cost in field2. Sometimes they leave field2 blank. How can I default to a value of 55.00 if field2 is null?
Thanks from me again.

Check out the Properties Form for Field2. There is a place for a Default Valuie. Is this what you are looking for?

If not, Check Out the On Update Event for the Record. You might be able to set the Default Value there.
 
FYI: Use the forms Before Update event to validate the current record before allowing the record to be saved.
 
I know about the default form Properties. I may not have been clear, I only want a default value if the checked the checkbox (field1), otherwise leave it blank.

Thanks for reply.
 
in the forms before update event, something like this...

Code:
If not isnull(checkbox1) and isnull(checkbox2) then
checkbox2 = "55"
end if
 
NO go ... gave me a micro error. But, it was a nice try ...
 
What error? (remember none of us can SEE what you see, so you have to describe things well. If I tell my doctor I have a pain, he's probably going to ask me to share more information like - where is it, how long have you had it, etc.)
 
Well, I think you have the code in the wrong place.

It should be:
Code:
Private Sub [B]KingSizeInd_After[/B]Update(Cancel As Integer)
  If Not IsNull([B]Me.[/B]KingSizeInd) And IsNull([B]Me.[/B]King[B][COLOR=red]_[/COLOR][/B]CHARGE) Then
        [B]Me.[/B]King[B][COLOR=red]_[/COLOR][/B]CHARGE = 55
  End If
End Sub

It looks like you had a naming issue because your Before Update event showed an underscore for the name (so it either has the underscore or a space) and so you have to use the same name in the code. And, you want the After Update of the CHECKBOX so that when it is checked and there isn't a value in the text box it will put a value there.
 
Copied your supplied code and put "After Update" on "KingSizeInd". Saved and opened form and entered data, but same thing. "KingCHARGE" was & is still bank ... NO DEFAULT VALUE.
 
Did you get the part where I said you have the wrong name in there?

KingCharge (according to your own posted code) is either

King_Charge

or

King Charge

it is not shown as the name

KingCharge.
 
Copied your supplied code and put "After Update" on "KingSizeInd". Saved and opened form and entered data, but same thing. "KingCHARGE" was & is still bank ... NO DEFAULT VALUE.

Point of clarification. SOS already said, and I will state again that we need to know if the name of the Field is [King Charge], [King_Charge], or [KingCharge]. So far it has been used all three ways without any comment as to whether misspellings were involved. For the record, I do not believe that it will matter what the name actually is (although [KingCharge] might be the best option), as long as all references use the same name. Verify that all references use the same name.
 
If you still can't get it, then uploading a copy here would probably solve the problem in about 10 seconds.
 
If you still can't get it, then uploading a copy here would probably solve the problem in about 10 seconds.

It might take me 30-60 seconds because I am not sure that this old computer could download a database that fast.
 
I've (ziped) & attached my database. Thanks so much for your help, time, & careing.
 

Attachments

Okay, the problem is that you have given us the wrong names....

The checkbox is NOT named KingSizeInd it is named Check72

And the text box is NOT named KingCharge, it is named King Charge (with a space in it).

So that would be the reason why things aren't working the way you want.

I will make modifications and reupload.
 
I'm so sorry!!! I've only been useing acxces for 2 & 1/2 weeks. I was going by the table names.
Thanks again!
 

Users who are viewing this thread

Back
Top Bottom