auto format

D

DaveB

On my form I have a field for BillingName, one for
LastName, and one for FirstName. If the Billing name is
not a business, then I want to use the LastName,
FirstName. I'd like to have it be automatically entered
into the field if I haven't already entered a business
name.

I asked about how to do this earlier in a different
field, but it doesn't do anything at all. Below is the VB.

Private Sub BillingAddress_AfterUpdate()
txtBillingAddress
If IsNull(Me.txtBillingAddress) Then
Me.txtBillingAddress = Me.txtJobAddress
End If
End Sub

Please tell me how to make it work.
 
S

SteveS

It depends on *when* you want the control to be updated. I would use the
OnExit event. This would require you to click (or tab) into the control;
when you leave (exit) the control, it runs the code.

Try this:

Private Sub BillingName_OnExit()
If IsNull(Me.txtBillingName) Then
Me.BillingName = Me.LastName & ", " & Me.FirstName
End If
End Sub


For the address:

Private Sub BillingAddress_OnExit()
If IsNull(Me.txtBillingAddress) Then
Me.txtBillingAddress = Me.txtJobAddress
End If
End Sub

Be sure to change the examples to use your control/field names.

HTH

Steve
 

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

Similar Threads


Top