On carrying the current value of a control forward...

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

Guest

The example code for this on the Access Web is not quite what I was hoping for.

When I enter a new record, I'd like the last value of that control to carry
forward, and if the user decides to type over it, I'd like THAT entry to
become the next and subsequent records' default value, until it is changed
again.

Can this be done On Enter or some other event, instead of being attached to
a button or other extra control as in Dev Ashish's example ?

tia
 
Ricter

In the control's AfterUpdate event, add code that sets that control's
DefaultValue to the control's value. It might look something like:

Me.YourControl.DefaultValue = Me.YourControl

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Jeff, I can't get this to work. I also tried using Me!, and I tried using
Before_Update...
 
Ricter

I don't know what to tell you... it works when I do it.

Perhaps if you posted the code you're using...?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Jeff, I got the following to work:

Private Sub Control_Exit(Cancel As Integer)
Const cQuote = """" 'Thats two quotes
Me!Control.DefaultValue = cQuote & Me!Control.Value & cQuote
End Sub

As you can see, all I did was use Dev Ashish's code, but put it in the Exit
event instead of attaching it to a button. I never did get
Me.Broker.DefaultValue=Me.Broker to work in any configuration or location.
 
You need

Me.Broker.DefaultValue=cQuote & Me.Broker & cQuote

or

Me.Broker.DefaultValue=Chr$(34) & Me.Broker & Chr$(34)

(even if the value is numeric)
 
Douglas, the first option, using only cQuote, does not work for me (unless I
define it as Ashish did), but Chr$(34) does. *shrug*

I also figured out that I don't need to define cQuote, as Dev Ashish does,
but can use Me.Control.DefaultValue = """" & Me. Control.Value & """".
Inelegant perhaps.

Thanks all!
 
Back
Top