Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set the focus of a form and a combo box to a new record

Status
Not open for further replies.

jlitondo

MIS
Jun 27, 2000
175
US
I have a main form with an Add New command button which opens up popup form for a new record entry. After closing this popup, I requery the main form and its combo box.Does anyone know how to set the focus of this main form and its combo to the newly entered record? jlitondo@gatecitysteel.com
 
Set focus
Dim SyncCriteria As String
Dim f As Form, rs As Recordset

Forms![Firstformname].requery

'Define the from object and recordset object for the AutoCAD form
Set f = Forms(Screen.ActiveForm.FormName)
Set rs = f.RecordsetClone

' define the criteria used for the sync
SyncCriteria = "[YourField]='" & Me![YourField] & "'"

' find the corresponding record in the Parts table
rs.FindFirst SyncCriteria
f.Bookmark = rs.Bookmark

Forms![Firstformname].form!Combobox.setfocus

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Thanks a bunch DougP! This is very interesting. The only thing is that "Forms![Firstformname].form!Combobox.setfocus" only sets focus on the combo box and clears out its text to show a blank combo box.So what I did is to assign my pk to a variable, requery my combo box and then reinitialise it to this variable so that the new record entered is also displayed in this combo box, i.e. Thanks again.

Forms!MyFormName!MyComboName.Requery
Forms!MyFormName!MyComboName = MyVariable
jlitondo@gatecitysteel.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top