copy default value to new record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Help ACCESS MVP's

I have a form with FAMILY, Address,City, ZIP & State.
My form works as follows.
If user selects Family="Y" then the address,city,zip & state value are
copied to the next new record. Which works perfect.

If family= "Y" Then
Address1.DefaultValue = "'" & Address1 & "'"
End If

BUT if the user selects family="N" the code does not clear the fields it
keeps copying the same field contents every time i enter a new record

If family= "N" Then
Address1.DefaultValue = "'" & Address1 & "'"
End If

Please help
Thanks
 
So you want to clear the Default Value if the Family field is the letter N?

If family= "N" Then
Address1.DefaultValue = ""
End If
 
Thanks for the response.

I have inserted the code after the code If Family='Y' then.., but it did not
work.
The code is in the afterupdated procedure.
Thanks for your assistance.
 
Didn't work means ?
Error mesage?
Did it run at all?
Try adding this line:
Debug.Print "Address1.DefaultValue is now " & Me.Address1.DefaultValue

Press Ctrl+G to open the Immediate window and see if anything printed there
after you expect it to run.

Is Family a Text field (so it contains the text "N" or "Y"), or is it a
yes/no field in which case you need:
If Me.Family = False Then
 
Thanks again.

I am sorry i was not clear in my response.

Whenever i choose "N" the value of the address does not change to blank ,
it leave the previously entered address information.

The family field is a combo with avalue list of "Y","N"

the command
Debug.Print "Address1.DefaultValue is now " & Me.Address1.DefaultValue
show the value that was enterd in the address field even when i choose
family="N"
I appreciate your assistance

Thanks
 
Thanks again.

I am sorry i was not clear in my response.

Whenever i choose "N" the value of the address does not change to blank ,
it leave the previously entered address information.

The family field is a combo with avalue list of "Y","N"

the command
Debug.Print "Address1.DefaultValue is now " & Me.Address1.DefaultValue
show the value that was enterd in the address field even when i choose
family="N"
I appreciate your assistance

Thanks
 
We can't see this, so you will need to do the debugging.

Add the line:
Stop
as the first line in the procedure.

When it runs, the code will stop, and highlight this line in yellow
Press F8 to single-step through the code, so you can see which lines are
executing. This should help you trace whether the code is running the lines
you expect, and whether they are working or what's happening. You can also
pause the mouse over a variable to see the value.
 
OK. Thanks

Allen Browne said:
We can't see this, so you will need to do the debugging.

Add the line:
Stop
as the first line in the procedure.

When it runs, the code will stop, and highlight this line in yellow
Press F8 to single-step through the code, so you can see which lines are
executing. This should help you trace whether the code is running the lines
you expect, and whether they are working or what's happening. You can also
pause the mouse over a variable to see the value.
 
Back
Top