setfocus problem

  • Thread starter forcefield via AccessMonster.com
  • Start date
F

forcefield via AccessMonster.com

I have a main form, frmMain with 2 subforms. By default, SubformSecond is
made invisible. SubformFirst is in datasheet view.
Before updating data in a textbox, txtPhyBal in subformFirst ,a message
popup form opens (fired by before update event of txtPhyBal).
On clicking an OK button on the message pop up form, the pop up form closes
and subformSecond becomes visible but the focus can be anywhere on the
subformFirst
What I like to do is to have the focus remains at txtPhyBal in SubformFirst

Private Sub OK_click()
Dim lngSkey As long
Dim rs as Dao.recordset
With Forms!frmMain.SubformFirst.Form
If txtboxQty>0 Then
Forms!frmMain.SubformSecond.Form.Visible= True
lngSkey= SubFormFirstID
‘ SubformFirstID is an autonumber.
Me.requery
Set rs = .RecordsetClone
rs.FindFirst “[SubFormFirstID] =†& lngSkey
If rs.NoMatch Then
Msgbox “Can’t find recordâ€
Else
.Bookmark = rs.bookmark
End if
Set rs = nothing

‘ I think the problem lies with the 2 statements below
Forms!frmMain.SubformFirst.Form.setfocus
Forms!frmMain.SubformFirst.Form.txtPhyQty.setfocus
Else
Forms!frmMain.SubformSecond.Form.Visible= False
End if
End with.
End sub

Can someone please help?
 
D

Douglas J. Steele

Try changing

Forms!frmMain.SubformFirst.Form.setfocus

to

Forms!frmMain.SubformFirst.SetFocus

You're setting focus on the subform control first, then you set focus to a
control on the form that's serving as the subform.
 
F

forcefield via AccessMonster.com

Thank you for your reply.
After changing the setfocus statement, the focus works only on current record.


In other word, after entering data in txtPhybal in SubformFirst and user
clicks any field on the current record as indicated by the record selector,
the PopUp form opens and on clicking the OK button on the PopUp form, the
focus will go back to current txtPhyBal in the SubformFirst (which is correct
and what I wanted).

However, if user were to click on other record other than the current one in
subformFirst (being in datasheet view) the focus will go to txtPhyBal on that
record. How do you force the focus back to the txtPhyBal on the current
record?

Try changing

Forms!frmMain.SubformFirst.Form.setfocus

to

Forms!frmMain.SubformFirst.SetFocus

You're setting focus on the subform control first, then you set focus to a
control on the form that's serving as the subform.
I have a main form, frmMain with 2 subforms. By default, SubformSecond is
made invisible. SubformFirst is in datasheet view.
[quoted text clipped - 35 lines]
Can someone please help?
 

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