D
DebbieG
In the Detail Section of a form, I have a combobox (ComboStudent) and a
textbox (ShowName). When I add a new record, I want the name to be
displayed so the user knows which student they're working with. My code
looks like this:
Private Sub ComboStudent_Change()
ShowName = ComboStudent.Column(1)
End Sub
Private Sub LastNM_LostFocus()
ShowName = LastNM & ", " & FirstNM & " " & MI
End Sub
Private Sub FirstNM_LostFocus()
ShowName = LastNM & ", " & FirstNM & " " & MI
End Sub
Private Sub MI_LostFocus()
ShowName = LastNM & ", " & FirstNM & " " & MI
End Sub
Private Sub Form_Current()
Me.cmdSave.Visible = False
Me.ComboStudent.Enabled = True
If Me.NewRecord = True Then
ComboStudent = vbNullString
ShowName = vbNullString '------------------ I also tried
ComboStudent.Column(1) and ""
Else
Me.AllowAdditions = False
Me.ComboStudent = Me.SSN
ShowName = ComboStudent.Column(1)
End If
End Sub
Everything is working fine, except if I type any part of the name in a new
record and then cancel the new record (by pressing ESC), the ComboStudent is
blank but the ShowName still has the name in it (I'm still in a new record).
Why does ShowName have something in it? I want it to be blank.
In fact, what I'd really like is if the user cancels the new record, I'd
like it to remove the new record and put me back in the first record. But I
can't figure out how to capture if they cancelled the new record, so this
was what I came up with.
Can anyone help me?
Debbie
textbox (ShowName). When I add a new record, I want the name to be
displayed so the user knows which student they're working with. My code
looks like this:
Private Sub ComboStudent_Change()
ShowName = ComboStudent.Column(1)
End Sub
Private Sub LastNM_LostFocus()
ShowName = LastNM & ", " & FirstNM & " " & MI
End Sub
Private Sub FirstNM_LostFocus()
ShowName = LastNM & ", " & FirstNM & " " & MI
End Sub
Private Sub MI_LostFocus()
ShowName = LastNM & ", " & FirstNM & " " & MI
End Sub
Private Sub Form_Current()
Me.cmdSave.Visible = False
Me.ComboStudent.Enabled = True
If Me.NewRecord = True Then
ComboStudent = vbNullString
ShowName = vbNullString '------------------ I also tried
ComboStudent.Column(1) and ""
Else
Me.AllowAdditions = False
Me.ComboStudent = Me.SSN
ShowName = ComboStudent.Column(1)
End If
End Sub
Everything is working fine, except if I type any part of the name in a new
record and then cancel the new record (by pressing ESC), the ComboStudent is
blank but the ShowName still has the name in it (I'm still in a new record).
Why does ShowName have something in it? I want it to be blank.
In fact, what I'd really like is if the user cancels the new record, I'd
like it to remove the new record and put me back in the first record. But I
can't figure out how to capture if they cancelled the new record, so this
was what I came up with.
Can anyone help me?
Debbie