G
Gator
Following is code that I click a button and the program makes sure that a
textbox (PayDate) is not null and if it is, then the textbox remains focused,
and if it is not null, then it proceeds to the tabbed control to a certain
page and to the subform. The subform's initial record is defaulted with the
field 'Fund Number' value of '0' and field 'Amount' with '$0.00'. When I
enter a date in the textbox the reaction is to start a new record rather than
the intended action of going to the subform. I think since there is a
default record of value 0 in the subform the program treats this as a not
null record and proceeds to the new record. How is the best way to fix this
that if the subform doesn't have another record other than '0' then it
highlights the first record, first field for entry. Also, will this work if
I hit enter after entering the date in the textbox? Should I enter this code
in a Private Sub PayDate_Enter ()?
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
If IsNull(Me.PayDate) Then
Me!PayDate.SetFocus
Else
Me.TabCtl27.Pages(0).SetFocus
Me.PayablesDetailssubform1.SetFocus
If IsNull(Me.PayablesDetailssubform1) Then
Me.TabCtl27.Pages(0).SetFocus
Me.PayablesDetailssubform1.SetFocus
Else
Me!PayDate.SetFocus
DoCmd.GoToRecord , , acNewRec
PayDate.SetFocus
End If
End If
Exit_Command10_Click:
Exit Sub
Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click
End Sub
textbox (PayDate) is not null and if it is, then the textbox remains focused,
and if it is not null, then it proceeds to the tabbed control to a certain
page and to the subform. The subform's initial record is defaulted with the
field 'Fund Number' value of '0' and field 'Amount' with '$0.00'. When I
enter a date in the textbox the reaction is to start a new record rather than
the intended action of going to the subform. I think since there is a
default record of value 0 in the subform the program treats this as a not
null record and proceeds to the new record. How is the best way to fix this
that if the subform doesn't have another record other than '0' then it
highlights the first record, first field for entry. Also, will this work if
I hit enter after entering the date in the textbox? Should I enter this code
in a Private Sub PayDate_Enter ()?
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
If IsNull(Me.PayDate) Then
Me!PayDate.SetFocus
Else
Me.TabCtl27.Pages(0).SetFocus
Me.PayablesDetailssubform1.SetFocus
If IsNull(Me.PayablesDetailssubform1) Then
Me.TabCtl27.Pages(0).SetFocus
Me.PayablesDetailssubform1.SetFocus
Else
Me!PayDate.SetFocus
DoCmd.GoToRecord , , acNewRec
PayDate.SetFocus
End If
End If
Exit_Command10_Click:
Exit Sub
Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click
End Sub