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
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