Command Button Problem

G Marshall

Board Regular
Joined
Dec 31, 2002
Messages
134
Hello

I have a form with a command button that has an "on click" event procedure. This procedure prints a service report and then moves to the next record. However when it moves to the next record the focus remains on the command button. I wish to set the focus on a text box on the new record which is called "ServiceRecordID".
The following is part of the code for the event procedure for the command button, what should I add to it to move the focus from the command button to my text box or indeed any other object on the form.

Dim strDocName As String
strDocName = "rptServiceReport"
' Print Service report, using qryServiceRecordsFilter query to print
' Service Report for current Service Record.
DoCmd.OpenReport strDocName, acViewNormal, "qryServiceRecordsFilter"
DoCmd.GoToRecord , , acNext

Appreciate any help

Gerald Marshall
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi G Marshall

quite simply you can use the .setfocus property

etc.

txt_my_textbox.setfocus
 
Upvote 0

Forum statistics

Threads
1,221,672
Messages
6,161,199
Members
451,688
Latest member
Gregs44132

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