Hi Sprinks
I transferred my code into the form's before update event. It now
works beautifully with some of my controls (when I do a search for
example) - I get my popup form which tells the user the compulsory
fields which have not been filled in. However when I click on
CmdNextRec (which moves the user to the next record) it comes up with
an error:
Runtime error 2105 "You can't go to the specified record"
The only code I now have on the CmdNextRec is:
DoCmd.GoToRecord, , acNext.
I have some code in the form's current event which I think may be
conflicting - although it was working fine before. It basically
enables and disables the cmds I use to navigate through the records.
Other than that there is some code which stores a couple of string
values to hold for comparison with the control when it is changed. I
have copied the code below. I'm getting very confused and tired - up
very late trying to work out what was going on!
Dim recClone As Recordset
'make a clone of the recordset underlying the form so _
we can move around that without affecting the form's recordset
Set recClone = Me.RecordsetClone()
'if we are in a new record, disable the <Next> button _
and enable the rest of the buttons
If Me.NewRecord Then
cmdFirstRec.Enabled = True
cmdPreviousRec.Enabled = True
CmdNextRec.Enabled = False
cmdLastRec.Enabled = True
CmdNewRec.Enabled = True
Exit Sub
End If
'If we reach here, we know we are not in a new record _
so we can enable the <New> buton if the form allows new records to be
added
CmdNewRec.Enabled = Me.AllowAdditions
'we need to check if there are no records. If so, we disable _
all buttons except for the <New> button
If recClone.RecordCount = 0 Then
cmdFirstRec.Enabled = False
cmdPreviousRec.Enabled = False
CmdNextRec.Enabled = False
cmdLastRec.Enabled = False
Else
'if there are records, we know that the <First> and _
<Last> buttons will always be enabled, irrespective _
of where we are in the recordset
cmdFirstRec.Enabled = True
cmdLastRec.Enabled = True
'Synchronise the current pointer in the current recordset and the
cloned recordset
recClone.Bookmark = Me.Bookmark
'Next we must see if we are on the first record _
if so, we should disable the <Previous> button
recClone.MovePrevious
'The previous button is enabled if we are not at the beginning of
the recordset or file
cmdPreviousRec.Enabled = Not (recClone.BOF)
recClone.MoveNext
'And then check whether we are on the last record _
if so, we should disable the <Next> button
recClone.MoveNext
'The Next button is enabled if we are not at the end of the
recordset or file
CmdNextRec.Enabled = Not (recClone.EOF)
recClone.MovePrevious
End If
'And finally close the cloned recordset
recClone.Close
'places the current class details into the temporary fields so the new
_
information can be compared with the old when the form is closed.
Dim strClass As String
Dim strStatus As String
Me!ClassName.SetFocus
strClass = Me!ClassName.Text
Me!Status.SetFocus
strStatus = Me!Status.Text
Me!TempStatus.SetFocus
Me!TempStatus.Text = strStatus
Me!TempClass.SetFocus
Me!TempClass.Text = strClass
Hi, Louise.
Yes; perhaps I misunderstood re: your control referrals. Just be sure that
if you're referring to a control on another form, you'll have to use full
syntax:
Forms![FormName]![ControlName]
Good luck. If I can help you further as you develop this application, let
me know.
Sprinks
Louise said:
Dear Sprinks
Thanks for help. I understand what you are saying about referring to
subforms correctly (as controls) but the pop-up form in my case is not a
sub-form, it is an unbound form just there for the purpose of giving a
reminder to the user as to which fields are not filled in. Or have I missed
the point?
I am going to move my code to the Before update event and have a look at
your tag property - will let you know how I get on.
Thanks, Louise