Changing data in Before Update

D

Dennis

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
 
J

John W. Vinson

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.
 
D

Dennis

John,

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

Thank you very much.

Dennis
 
D

Dennis

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
 
J

John W. Vinson

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

Either works in this context; the . is a "method" of the form object, and the
! is a member of the form's default Collection (which is its controls). I
don't know if there is any practical difference (though using . will make
editing code a mite easier since it will intelligently complete).
 
D

Dennis

John,

Thanks for the info.

I have so much more to learn. The sad thing is, each time I learn some I
realize how little I know, the learning cliff get higher, and my head hurts
just a little more.

Dennis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top