New record foulup

  • Thread starter Thread starter RipperT
  • Start date Start date
R

RipperT

Hi,

I have a subform on a form. The two are linked by a common field. Users
select a record on the main form and then may enter a record(s) in the
subform. My trouble is that if the user moves to create a new record on the
main form or the subform, the app will not allow the user to go anywhere
else until the first field of the sub form is filled in. It is a required
field, but the user may mistakenly choose a new record and then want to back
out, or click in another field. This doesn't happen when working directly in
the table, where Access doesn't complain until you try to save the record.
How do I get around this behavior?

Many thanx,

Rip
 
RipperT said:
I have a subform on a form. The two are linked by a common field. Users
select a record on the main form and then may enter a record(s) in the
subform. My trouble is that if the user moves to create a new record on the
main form or the subform, the app will not allow the user to go anywhere
else until the first field of the sub form is filled in. It is a required
field, but the user may mistakenly choose a new record and then want to back
out, or click in another field. This doesn't happen when working directly in
the table, where Access doesn't complain until you try to save the record.


That's normally because the user actually started to enter
something (i.e. the record is dirty). The user can hit the
Escape (twice) key to back out all the changes to the record
and then should be able to navigate to a different record.

If this happens without the user hitting a key, then you
have some code that is dirtying the form. This would be a
No No on your part and more details would be required before
I could help straighten it out.
 
I had thought of that. I've removed all default values, including that of an
option group and still no go. Are you saying that form and subform must be
'clean' in order to avoid this, or just the sub form? (the subform is the
source of the error message). The main form has a wizard created-Close
button, the subform contains this:

Private Sub Form_Current()
If Me.optMembership = "2" Then
Me.Team.Enabled = True
Else: Me.Team.Enabled = False
Me.Team = ""
End If
End Sub

Private Sub optMembership_AfterUpdate()
If Me.optMembership = "2" Then
Me.Team.Enabled = True
Else: Me.Team.Enabled = False
Me.Team = ""
End If
End Sub

I tried switching the order of the two else statements in each sub, and also
tried using Null instead of an empty String, to no avail.

Would these subs be causing it somehow?

Thanx for the reponse,

Rip
 
I don't have enough details to figure out exactly what's
going on, but I am concerned about the line
Me.Team = ""
in the Current event.

If Team is a bound text box, then that line will dirty a new
record and start the troubles you're seeing.

Futhermore, if that's a bound text box, that line would be
changing a value in every record that you navigate to on the
screen, which is defintely a very bad thing to do.

Note that using the DefaulValue property on controls will
**not** cause any of the problems you're experiencing.
Default values are not actually assigned as a control's
Value until the record becomes dirty and can be "backed out"
by using the Escape key twice to undo all user data entry on
the current record.
 
I've removed the culprit line from the Current event, but left it in the
after update event and it seems to be working OK now. Many thanx for the
help.

Rip

--
Ripper T Smith
rippertsmith<nospam>@comcast.net
Marshall Barton said:
I don't have enough details to figure out exactly what's
going on, but I am concerned about the line
Me.Team = ""
in the Current event.

If Team is a bound text box, then that line will dirty a new
record and start the troubles you're seeing.

Futhermore, if that's a bound text box, that line would be
changing a value in every record that you navigate to on the
screen, which is defintely a very bad thing to do.

Note that using the DefaulValue property on controls will
**not** cause any of the problems you're experiencing.
Default values are not actually assigned as a control's
Value until the record becomes dirty and can be "backed out"
by using the Escape key twice to undo all user data entry on
the current record.
--
Marsh
MVP [MS Access]



RipperT said:
I had thought of that. I've removed all default values, including that of
an
option group and still no go. Are you saying that form and subform must be
'clean' in order to avoid this, or just the sub form? (the subform is the
source of the error message). The main form has a wizard created-Close
button, the subform contains this:

Private Sub Form_Current()
If Me.optMembership = "2" Then
Me.Team.Enabled = True
Else: Me.Team.Enabled = False
Me.Team = ""
End If
End Sub

Private Sub optMembership_AfterUpdate()
If Me.optMembership = "2" Then
Me.Team.Enabled = True
Else: Me.Team.Enabled = False
Me.Team = ""
End If
End Sub

I tried switching the order of the two else statements in each sub, and
also
tried using Null instead of an empty String, to no avail.


"Marshall Barton" wrote
 
Back
Top