How do I stop the code?

  • Thread starter Thread starter dbl
  • Start date Start date
D

dbl

Hi I am using the following to duplicate certain fields in a new record
which works fine.
When I add the new record all the fields I have listed are copied. I am
using the on Click event to trigger the code but how do I stop it?
Every time I add a new record I get the same date in my fields.

Const cQuote = """"
Me.DriverFirstName.DefaultValue = cQuote & Me.DriverFirstName.Value &
cQuote
Me.DriverLastName.DefaultValue = cQuote & Me.DriverLastName.Value &
cQuote
Me.RegistrationNumber.DefaultValue = cQuote &
Me.RegistrationNumber.Value & cQuote

The second problem I have when I add a new record using the above the
following code over writes the Registration Number

DoCmd.GoToRecord , , A_NEWREC
Me.RegistrationNumber = "XXXXXXX"

Any help would be very much appreciated.

Thanks Bob
 
Hi,

I get results like that whenever I try to use code with Continuous Forms. I
hope your problem is as easy as that to fix.

Hunter57
 
You're telling Access to make the defaults for these fields the same as the
values for the fields in the current record. If you don't want this to
contimue to be the default, you have to "reset" the defaults after the new
record is created:

Me.DriverFirstName.DefaultValue = ""
Me.DriverLastName.DefaultValue = ""
Me.RegistrationNumber.DefaultValue = ""

As to your statement "The second problem I have when I add a new record using
the above the
following code over writes the Registration Number," well, not to be impolite,
but "Duh!"

Your line of code:

Me.RegistrationNumber = "XXXXXXX"

is telling Access to overwrite the RegistrationNumber with "XXXXXXX"!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
Hi well that doesn't work it produces an error item not found in this
collection. The reason the Registration Number is all X's is so that its
easy to identify if a Registration number wasn't known at the point of data
entry.

Bob
 
Back
Top