From: Dennis on
Hi,

I'm running Access XP on Windows 7.

I have a screen where I have to have potentially repetative information for
each entry. One such field is vendor invoice number. I have the code to
track the last invoice number entere. Now, I would like to be able to enter
an "L" (for last) as the first character, hit enter, and have the software
set the current invoice number ot the the last entered invoice numbered
entered (or whatever field).

I'm currently doing this in the control's BeforeUpdate event. Apparantly,
this is the wrong way to do this.

Note: The control txtInvoiceNo is bound to the data field InvoiceNo.

Here is my code in the control's BeforeUpdate event:

If IsNull(Me.txtInvoiceNo) Then Me.txtInvoiceNo = ""
strInvNo = UCase(Me.txtInvoiceNo)
If strInvNo = "L" Then Me.txtInvoiceNo = pstrLastInvNo


What is the correct or "best" way to do this?

By the way, pstrLastInvNo is set to me.txtInvoiceNo in the
txtInvoiceNo_AfterUpdate event.


Thanks for your assitance.

Dennis
From: Arvin Meyer [MVP] on
I use the control's AfterUpdate event.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access


"Dennis" <Dennis(a)discussions.microsoft.com> wrote in message
news:3094D488-3008-4F5D-A74E-DAF6E17EF095(a)microsoft.com...
> Hi,
>
> I'm running Access XP on Windows 7.
>
> I have a screen where I have to have potentially repetative information
> for
> each entry. One such field is vendor invoice number. I have the code to
> track the last invoice number entere. Now, I would like to be able to
> enter
> an "L" (for last) as the first character, hit enter, and have the software
> set the current invoice number ot the the last entered invoice numbered
> entered (or whatever field).
>
> I'm currently doing this in the control's BeforeUpdate event. Apparantly,
> this is the wrong way to do this.
>
> Note: The control txtInvoiceNo is bound to the data field InvoiceNo.
>
> Here is my code in the control's BeforeUpdate event:
>
> If IsNull(Me.txtInvoiceNo) Then Me.txtInvoiceNo = ""
> strInvNo = UCase(Me.txtInvoiceNo)
> If strInvNo = "L" Then Me.txtInvoiceNo = pstrLastInvNo
>
>
> What is the correct or "best" way to do this?
>
> By the way, pstrLastInvNo is set to me.txtInvoiceNo in the
> txtInvoiceNo_AfterUpdate event.
>
>
> Thanks for your assitance.
>
> Dennis


From: John W. Vinson on
On Tue, 16 Mar 2010 20:32:01 -0700, Dennis <Dennis(a)discussions.microsoft.com>
wrote:

>I have a screen where I have to have potentially repetative information for
>each entry. One such field is vendor invoice number. I have the code to
>track the last invoice number entere. Now, I would like to be able to enter
>an "L" (for last) as the first character, hit enter, and have the software
>set the current invoice number ot the the last entered invoice numbered
>entered (or whatever field).

Would it perhaps be even easier to make the invoice number "sticky" - so that
each new entry defaults to the previous entry, but can be overtyped?

To do so use the textbox's AfterUpdate event:

Private Sub txtInvoiceNo_AfterUpdate()
Me!txtInvoiceNo.DefaultValue = """" & Me!txtInvoiceNo & """"
End Sub

The quotes are because the default value property must be a String.
--

John W. Vinson [MVP]
From: Dennis on
John,

Yes, it would be much easier to make the invoice number "sticky"!!!!!!

Thank you very much.

Dennis




From: Dennis on
John,

One question (I'm still climbing the learning cliff).


Normally I write

me.txtInvoiceNo =

you wrote

me!txtInvoiceNo =

why did you use ! instead of . after me?

Dennis