BeforeUpdate and closing form

LEXCERM

Active Member
Joined
Jun 26, 2004
Messages
320
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have the following code in a BeforeUpdate event of a field:-

cmd_PONumberSearch_Click 'activates requery from button
With Me.txt_PONumber
.SelStart = 0
.SelLength = Len(Me.txt_PONumber.Text)
End With
Cancel = True

This is used for continuous searches in a subform and sets focus back on the text field to make it easier for the user.

Problem being, if this field has the focus I cannot close the form via a command button.

What is the trick here?

Kind regards.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I dont see the point of this code....it highlights the text in a box, then does nothing.
why?
 
Upvote 0
Hi ranman256,

It saves an extra 'click' selection in the field before entering the next value. Especially if you have many PO's to check.
 
Upvote 0
Problem being, if this field has the focus I cannot close the form via a command button.

What is the trick here?

Kind regards.

In the code for the command button that closes the form, move the focus to another control before closing the form.
Example:

Me.MyControlName.SetFocus

or

Docmd.GoToControl "MyControlName"
 
Upvote 0

Forum statistics

Threads
1,221,848
Messages
6,162,419
Members
451,765
Latest member
craigvan888

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top