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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't get rid of the focus on movng to next record

Status
Not open for further replies.

capndave

Technical User
Mar 4, 2003
36
US
I have this code in the AfterUpdate event for the OccurType field on the main form:

Dim sfrm As Form

Set sfrm = [frmsubTxnDetail].Form

If Me!TypeOccur = "60" Then
sfrm!cboTxnRxn.Visible = True
Else
sfrm!cboTxnRxn.Visible = False
End If

Set sfrm = Nothing


End Sub

Which works fine (thanks to AceMan1)for data entry. However I want the cboTxnRxn on the subform to be visible under the same conditions when moving through existing records so I have this code in the OnCurrent event for the main form:

Dim sfrm As Form

Set sfrm = [frmsubTxnDetail].Form

If Me!TypeOccur = "60" Then
sfrm!cboTxnRxn.Visible = True
Forms!OccurEntry![OccurDate].SetFocus
Else
'Me.OccurEntry.SetFocus
[OccurDate].SetFocus
sfrm!cboTxnRxn.Visible = False

End If

Set sfrm = Nothing

The code works until I move from a record where TypeOccur=60 to a record where it does not in which case the OccurDate field appears to have the focus (the cursor is there)but I get an error message that I can't hide control that has the focus. Furthermore I need to have a number of different "If OccurType=different numbers to display different cbo in the subform.

If someone could tell me where I went wrong and how to code the multiple "ifs" I would be greatful as I have already spent 2 hours trying to make it work. Thanks
 
Unfortuantely, there is no 'nice' way round this.

The only option is to ensure the focus is on a control that will never be hidden.

in the on current, run the following BEFORE the if

mycontrol.setfocus (where mycontrol is a control that is always visible)

If you do not have a control that is always visible, create one!

Put a unbound text box in a corner, set it's height and width to 0, give it a name, and use that. Remember they a pain to find if you forget, so make sure you add a comment in the code about what the control is!

SeeThru
Synergy Connections Ltd - Telemarketing Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top